You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dirk vanGulik <Di...@jrc.it> on 1996/07/24 10:47:49 UTC

malloc patch

Has some-one committed something like this, which
plugs a malloc() fail centrally ?

Tha !

Dw.



*** alloc.org.c	Wed Jul 24 10:31:48 1996
--- alloc.c	Wed Jul 24 10:44:24 1996
***************
*** 49,64 ****
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
!  */
! 
! 
! /*
   * Resource allocation code... the code here is responsible for making
   * sure that nothing leaks.
   *
   * rst --- 4/95 --- 6/95
   */
  
  #include "conf.h"
  #include "alloc.h"
  
--- 49,67 ----
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
!  *
   * Resource allocation code... the code here is responsible for making
   * sure that nothing leaks.
   *
   * rst --- 4/95 --- 6/95
+  *
+  * Dirk.vanGulik@jrc.it - Added some code which makes it barf when
+  *		            it cannot malloc memory; this saves a lot
+  *			    of checks further down in the code.
   */
  
+ #define FATAL_MALLOC 1
+ 
  #include "conf.h"
  #include "alloc.h"
  
***************
*** 108,114 ****
    union block_hdr *blok =
      (union block_hdr *)malloc(size + sizeof(union block_hdr));
  
!   if (blok == NULL) return NULL;
    
    blok->h.next = NULL;
    blok->h.first_avail = (char *)(blok + 1);
--- 111,122 ----
    union block_hdr *blok =
      (union block_hdr *)malloc(size + sizeof(union block_hdr));
  
!   if (blok == NULL) {
! 	fprintf(stderr,"httpd: Fatal, Could not claim %d bytes of memory\n",
! 		size+ sizeof(union block_hdr));
! 
! 	exit(errno ? errno : FATAL_MALLOC);
! 	};
    
    blok->h.next = NULL;
    blok->h.first_avail = (char *)(blok + 1);



Re: malloc patch

Posted by Alexei Kosut <ak...@organic.com>.
On Wed, 24 Jul 1996, Dirk vanGulik wrote:

> Has some-one committed something like this, which
> plugs a malloc() fail centrally ?

+1 on the patch, except for one thing:

> +  *
> +  * Dirk.vanGulik@jrc.it - Added some code which makes it barf when
> +  *		            it cannot malloc memory; this saves a lot
> +  *			    of checks further down in the code.

Sorry, but no. -1 Do not pass go, do not collect $200. RST gets his name
there because he wrote the original code, so does Rob M if he wrote it.
We also put names in some of the modules people wrote or totall rewrote on
their own, like mod_status or mod_actions or mod_imap. But if you get your
name in the code for a seven line patch, then I demand my name in all the
peices of code *I've* written. And so will everyone else. I just don't
think this is appropriate. CVS keeps logs, we don't need them in the
files.

There have been a lot of modifications to alloc.c since version 0.8.0 of
Apache, when it was introduced, like there have been to all the files.
None of them got attribution, neither do yours.

A little thing, but IMHO it's important.

-- Alexei Kosut <ak...@organic.com>            The Apache HTTP Server 
   http://www.nueva.pvt.k12.ca.us/~akosut/      http://www.apache.org/