2024-07-25 10:27:17 +02:00

36 lines
513 B
C
Executable File

/*
FORTRAN callable routine to allocate a block of memory of size n bytes
*/
#include <stdlib.h>
#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