00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include "common.h"
00005 #include "mem.h"
00006
00007
00008
00009
00010
00011
00012
00013 void *mem_alloc (unsigned long block, char *item)
00014 {
00015
00016 void *ptr;
00017
00018 ptr = (void *) malloc (block);
00019
00020 if (ptr != NULL) {
00021 memset (ptr, 0, block);
00022 } else {
00023 fprintf (stderr, "Unable to allocate %s\n", item);
00024 exit (0);
00025 }
00026 return (ptr);
00027 }
00028
00029
00030
00031
00032
00033
00034
00035
00036 void mem_free (void **ptr_addr)
00037 {
00038
00039 if (*ptr_addr != NULL) {
00040 free (*ptr_addr);
00041 *ptr_addr = NULL;
00042 }
00043
00044 }