httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk vanGulik <Dirk.vanGu...@jrc.it>
Subject malloc patch
Date Wed, 24 Jul 1996 08:47:49 GMT
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);



Mime
View raw message