/*************************************************************************** * Copyright (C) 1994 Charles P. Peterson * * 4007 Enchanted Sun, San Antonio, Texas 78244-1254 * * Email: Charles_P_Peterson@fcircus.sat.tx.us * * * * This is free software with NO WARRANTY. * * See gfft.c, or run program itself, for details. * * Support is available for a fee. * *************************************************************************** * * Program: gfft--General FFT analysis * File: galloc.c * Purpose: memory allocation * Author: Charles Peterson (CPP) * History: 2-June-1993 CPP; Created. * Comments: These are layer(s) on top of malloc and free. * If system doesn't automatically deallocate memory on exit() * special handling could be added here. * If malloc fails, longjmp is called to return to main loop * in gfft, or a more recent setjmp. */ #include #include "gfft.h" void* gmalloc (unsigned long bytes, int jmp_value) { void *memblock = malloc ((size_t) bytes); if (!memblock) { error_message (OUT_OF_MEMORY); RAISE_ERROR (jmp_value); } return memblock; } void* grealloc (void *memblock, unsigned long bytes, int jmp_value) { memblock = realloc (memblock, (size_t) bytes); if (!memblock) { error_message (OUT_OF_MEMORY); RAISE_ERROR (jmp_value); } return memblock; } void* gcalloc (unsigned long n_ele, unsigned long ele_size, int jmp_value) { void *memblock = calloc ((size_t) n_ele, (size_t) ele_size); if (!memblock) { error_message (OUT_OF_MEMORY); RAISE_ERROR (jmp_value); } return memblock; } void gfree (void* block) { free (block); }