/* FORTRAN callable routine to allocate a block of memory of size n bytes */ #include #define FC_FUNC(name,NAME) name ## _ #define xalloc FC_FUNC(xalloc,XALLOC) #define xdealloc FC_FUNC(xdealloc,XDEALLOC) typedef long int xaddr_t; #ifdef __cplusplus extern "C" { #endif static void *memptr; xaddr_t xalloc(xaddr_t *n) { memptr = malloc((size_t) *n); if ( memptr == NULL ) { return (xaddr_t) 0; } return (xaddr_t) memptr; } void xdealloc() { free(memptr); } #ifdef __cplusplus } #endif