You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@attglobal.net> on 2003/06/20 16:33:48 UTC

[1.3 PATCHLET] how big was that malloc that failed?

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

Re: [1.3 PATCHLET] how big was that malloc that failed?

Posted by Bill Stoddard <bi...@wstoddard.com>.
+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));
>  
>



Re: [1.3 PATCHLET] how big was that malloc that failed?

Posted by Jim Jagielski <ji...@jagunet.com>.
+1

On Friday, June 20, 2003, at 10:33  AM, 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));