Received: by taz.hyperreal.com (8.6.12/8.6.5) id BAA12173; Wed, 24 Jul 1996 01:49:08 -0700 Received: from dicsmss1.jrc.it by taz.hyperreal.com (8.6.12/8.6.5) with SMTP id BAA12167; Wed, 24 Jul 1996 01:49:03 -0700 Received: from jrc.it (elect6.jrc.it) by dicsmss1.jrc.it (4.1/EB-950131-C) id AA08291; Wed, 24 Jul 96 10:52:47 +0200 Received: by jrc.it (5.x/EB-950213-L) id AA09619; Wed, 24 Jul 1996 10:47:49 +0200 Date: Wed, 24 Jul 1996 10:47:49 +0200 From: Dirk vanGulik Message-Id: <9607240847.AA09619@ jrc.it> To: new-httpd@hyperreal.com Subject: malloc patch X-Sun-Charset: US-ASCII Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com 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 . * ! */ ! ! ! /* * 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 . * ! * * 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);