alloc functions may take 0 for the size

This commit is contained in:
Yuichi Nishiwaki 2014-01-18 07:33:51 -08:00
parent c85e07b7ee
commit 9495e9bf5c
1 changed files with 3 additions and 3 deletions

View File

@ -90,7 +90,7 @@ pic_alloc(pic_state *pic, size_t size)
void *ptr;
ptr = malloc(size);
if (ptr == NULL) {
if (ptr == NULL && size > 0) {
pic_abort(pic, "memory exhausted");
}
return ptr;
@ -100,7 +100,7 @@ void *
pic_realloc(pic_state *pic, void *ptr, size_t size)
{
ptr = realloc(ptr, size);
if (ptr == NULL) {
if (ptr == NULL && size > 0) {
pic_abort(pic, "memory exhausted");
}
return ptr;
@ -112,7 +112,7 @@ pic_calloc(pic_state *pic, size_t count, size_t size)
void *ptr;
ptr = calloc(count ,size);
if (ptr == NULL) {
if (ptr == NULL && size > 0) {
pic_abort(pic, "memory exhausted");
}
return ptr;