/* -----------------------------------------------------------------------------
* Author(s): David Beazley (beazley@cs.uchicago.edu)
* This library file contains macros that can be used to create objects using
* $Header: /cvsroot/swig/SWIG/Lib/cmalloc.i,v 1.5 2004/11/28 19:15:04 wsfulton Exp $
* ----------------------------------------------------------------------------- */
/* %malloc(TYPE [, NAME = TYPE])
%calloc(TYPE [, NAME = TYPE])
%realloc(TYPE [, NAME = TYPE])
%free(TYPE [, NAME = TYPE])
%allocators(TYPE [,NAME = TYPE])
Creates functions for allocating/reallocating memory.
TYPE *malloc_NAME(int nbytes = sizeof(TYPE);
TYPE *calloc_NAME(int nobj=1, int size=sizeof(TYPE));
TYPE *realloc_NAME(TYPE *ptr, int nbytes);
void free_NAME(TYPE *ptr);
%define %malloc(TYPE,NAME...)
%rename(malloc_##NAME) ::malloc(int nbytes);
%rename(malloc_##TYPE) ::malloc(int nbytes);
%typemap(default) int nbytes "$1 = (int) sizeof(TYPE);"
TYPE *malloc(int nbytes);
%typemap(default) int nbytes;
%define %calloc(TYPE,NAME...)
%rename(calloc_##NAME) ::calloc(int nobj, int sz);
%rename(calloc_##TYPE) ::calloc(int nobj, int sz);
%typemap(default) int sz "$1 = (int) sizeof(TYPE);"
%typemap(default) int sz "$1 = 1;"
%typemap(default) int nobj "$1 = 1;"
TYPE *calloc(int nobj, int sz);
%typemap(default) int sz;
%typemap(default) int nobj;
%define %realloc(TYPE,NAME...)
TYPE *realloc_##NAME(TYPE *ptr, int nitems)
TYPE *realloc_##TYPE(TYPE *ptr, int nitems)
return (TYPE *) realloc(ptr, nitems*sizeof(TYPE));
return (TYPE *) realloc(ptr, nitems);
TYPE *realloc_##NAME(TYPE *ptr, int nitems);
TYPE *realloc_##TYPE(TYPE *ptr, int nitems);
%define %free(TYPE,NAME...)
%rename(free_##NAME) ::free(TYPE *ptr);
%rename(free_##TYPE) ::free(TYPE *ptr);
%define %sizeof(TYPE,NAME...)
%constant int sizeof_##NAME = sizeof(TYPE);
%constant int sizeof_##TYPE = sizeof(TYPE);
%define %allocators(TYPE,NAME...)