This is one of those "Use the source, Luke" questions. malloc() is the normal system malloc() and emalloc() is a #define which points to _emalloc() which is the internal safety net version. When you get memory from emalloc(), even if you forget to free it, you won't leak because it will be cleaned up for you at request end. Also, in debug mode it gives you info on where things were allocated and it watches for overflows. It also checks the memory limit setting.
So, basically you should always use emalloc. The only time you may need to use the real malloc() is when you need to allocate some memory that some 3rd-party library might free on you. Everything else should be emalloc'ed. -Rasmus On Sun, 29 Sep 2002, Jon Parise wrote: > Could someone please describe the differences between malloc() and > emalloc()? I'd like to know when I should be using one instead of the > other. I don't see this topic mentioned in the coding standards, and > they appear to be used interchangeably (although not mixed) throughout > the current code. > > -- > Jon Parise ([EMAIL PROTECTED]) :: The PHP Project (http://www.php.net/) > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php