PORT_Alloc and PORT_ZAlloc always allocate at least one byte, even if

the caller requests zero bytes.  This patch makes PORT_ArenaAlloc
and PORT_ArenaZAlloc do the same.
This commit is contained in:
nelsonb%netscape.com 2003-06-03 23:24:31 +00:00
Родитель c4e55ac971
Коммит 81e3889b8f
1 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -38,7 +38,7 @@
*
* NOTE - These are not public interfaces
*
* $Id: secport.c,v 1.14 2002-05-01 00:06:39 wtc%netscape.com Exp $
* $Id: secport.c,v 1.15 2003-06-03 23:24:31 nelsonb%netscape.com Exp $
*/
#include "seccomon.h"
@ -210,10 +210,14 @@ PORT_NewArena(unsigned long chunksize)
void *
PORT_ArenaAlloc(PLArenaPool *arena, size_t size)
{
void *p;
void *p = NULL;
PORTArenaPool *pool = (PORTArenaPool *)arena;
if (size <= 0) {
size = 1;
}
/* Is it one of ours? Assume so and check the magic */
if (ARENAPOOL_MAGIC == pool->magic ) {
PZ_Lock(pool->lock);
@ -245,7 +249,12 @@ PORT_ArenaAlloc(PLArenaPool *arena, size_t size)
void *
PORT_ArenaZAlloc(PLArenaPool *arena, size_t size)
{
void *p = PORT_ArenaAlloc(arena, size);
void *p;
if (size <= 0)
size = 1;
p = PORT_ArenaAlloc(arena, size);
if (p) {
PORT_Memset(p, 0, size);