cs_malloc.c
Go to the documentation of this file.
00001 #include "cs.h"
00002 #ifdef MATLAB_MEX_FILE
00003 #define malloc mxMalloc
00004 #define free mxFree
00005 #define realloc mxRealloc
00006 #define calloc mxCalloc
00007 #endif
00008 
00009 /* wrapper for malloc */
00010 void *cs_malloc (int n, size_t size)
00011 {
00012     return (malloc (CS_MAX (n,1) * size)) ;
00013 }
00014 
00015 /* wrapper for calloc */
00016 void *cs_calloc (int n, size_t size)
00017 {
00018     return (calloc (CS_MAX (n,1), size)) ;
00019 }
00020 
00021 /* wrapper for free */
00022 void *cs_free (void *p)
00023 {
00024     if (p) free (p) ;       /* free p if it is not already NULL */
00025     return (NULL) ;         /* return NULL to simplify the use of cs_free */
00026 }
00027 
00028 /* wrapper for realloc */
00029 void *cs_realloc (void *p, int n, size_t size, int *ok)
00030 {
00031     void *pnew ;
00032     pnew = realloc (p, CS_MAX (n,1) * size) ; /* realloc the block */
00033     *ok = (pnew != NULL) ;                  /* realloc fails if pnew is NULL */
00034     return ((*ok) ? pnew : p) ;             /* return original p if failure */
00035 }


hogman_minimal
Author(s): Maintained by Juergen Sturm
autogenerated on Mon Oct 6 2014 00:06:58