mirror of
https://code.it4i.cz/sccs/easyconfigs-it4i.git
synced 2025-04-17 04:00:49 +01:00
36 lines
513 B
C
Executable File
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
|