diff options
Diffstat (limited to 'libtoolame-dab/mem.c')
-rw-r--r-- | libtoolame-dab/mem.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libtoolame-dab/mem.c b/libtoolame-dab/mem.c new file mode 100644 index 0000000..216ec2b --- /dev/null +++ b/libtoolame-dab/mem.c @@ -0,0 +1,44 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "common.h" +#include "mem.h" + +/******************************************************************************* +* +* Allocate number of bytes of memory equal to "block". +* +*******************************************************************************/ + +void *mem_alloc (unsigned long block, char *item) +{ + + void *ptr; + + ptr = (void *) malloc (block); + + if (ptr != NULL) { + memset (ptr, 0, block); + } else { + fprintf (stderr, "Unable to allocate %s\n", item); + exit (0); + } + return (ptr); +} + + +/**************************************************************************** +* +* Free memory pointed to by "*ptr_addr". +* +*****************************************************************************/ + +void mem_free (void **ptr_addr) +{ + + if (*ptr_addr != NULL) { + free (*ptr_addr); + *ptr_addr = NULL; + } + +} |