httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Stoddard <b...@wstoddard.com>
Subject Re: [1.3 PATCHLET] how big was that malloc that failed?
Date Fri, 20 Jun 2003 14:47:44 GMT
+1

Jeff Trawick wrote:

> to help divide the search space between
>
> a) some module accidentally asked for some obscene amount of storage, 
> which could not be satisfied
>
> b) some ordinary storage allocation request failed for any of various 
> reasons
>
>------------------------------------------------------------------------
>
>Index: src/main/alloc.c
>===================================================================
>RCS file: /home/cvs/apache-1.3/src/main/alloc.c,v
>retrieving revision 1.144
>diff -u -r1.144 alloc.c
>--- src/main/alloc.c	21 Apr 2003 20:00:19 -0000	1.144
>+++ src/main/alloc.c	20 Jun 2003 14:32:37 -0000
>@@ -219,6 +219,7 @@
> static union block_hdr *malloc_block(int size)
> {
>     union block_hdr *blok;
>+    int request_size;
> 
> #ifdef ALLOC_DEBUG
>     /* make some room at the end which we'll fill and expect to be
>@@ -230,9 +231,11 @@
>     ++num_malloc_calls;
>     num_malloc_bytes += size + sizeof(union block_hdr);
> #endif
>-    blok = (union block_hdr *) malloc(size + sizeof(union block_hdr));
>+    request_size = size + sizeof(union block_hdr);
>+    blok = (union block_hdr *) malloc(request_size);
>     if (blok == NULL) {
>-	fprintf(stderr, "Ouch!  malloc failed in malloc_block()\n");
>+	fprintf(stderr, "Ouch!  malloc(%d) failed in malloc_block()\n",
>+                request_size);
> 	exit(1);
>     }
>     debug_fill(blok, size + sizeof(union block_hdr));
>  
>



Mime
View raw message