spmalloc.h

Go to the documentation of this file.
00001 #ifndef __SPMALLOC_H__
00002 #define __SPMALLOC_H__
00003 
00004 #include <stdlib.h>
00005 #include "MALLOC.h"
00006 #define SPMALLOC(x) MALLOC(((size_t) x))
00007 #define SPALLOC(type,number)  ((type *)SPMALLOC((unsigned)(sizeof(type)*(number))))
00008 #define SPREALLOC(ptr,type,number)  \
00009            ptr = (type *)REALLOC((char *)ptr,(unsigned)(sizeof(type)*(number)))
00010 
00011 #define SPFREE(ptr) { if ((ptr) != NULL) {FREE((void *)(ptr)); (ptr) = NULL;}}
00012 
00013 
00014 /* Calloc that properly handles allocating a cleared vector. */
00015 #define SPCALLOC(ptr,type,number)                         \
00016 {   int i; ptr = SPALLOC(type, number);                   \
00017     if (ptr != (type *)NULL)                            \
00018         for(i=(number)-1;i>=0; i--) ptr[i] = (type) 0;  \
00019 }
00020 
00021 #endif /*__SPMALLOC_H__*/

Generated on Sun Mar 4 15:04:00 2007 for Scilab [trunk] by  doxygen 1.5.1