Re: CODING_STANDARDS addition re: emalloc

From: Date: Wed, 09 Oct 2002 13:47:10 +0000
Subject: Re: CODING_STANDARDS addition re: emalloc
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-89281@lists.php.net to get a copy of this message
A new CODING_STANDARDS patch is attached, based on feedback from Andi and Dan (thanks!). Please review and comment. -- Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)

Index: CODING_STANDARDS =================================================================== RCS file: /repository/php4/CODING_STANDARDS,v retrieving revision 1.22 diff -u -r1.22 CODING_STANDARDS --- CODING_STANDARDS 9 Sep 2002 07:54:11 -0000 1.22 +++ CODING_STANDARDS 9 Oct 2002 13:41:35 -0000 @@ -122,6 +122,20 @@ existing. End users should use function_exists() to test for the existence of a function +[11] Prefer emalloc(), efree(), estrdup(), etc. to their standard C library + counterparts. These functions implement an internal "safety-net" + mechanism that ensures the deallocation of any unfreed memory at the + end of a request. They also provide useful allocation and overflow + information while running in debug mode. + + In almost all cases, memory returned to the engine must be allocated + using emalloc(). + + malloc() should only be used in instances where you need to allocate + memory that will be freed (via free()) inside of a third-party library. + It should also be used in instances where allocated memory has to + survive between multiple requests. + Naming Conventions ------------------
« previous php.dev (#89281) next »