cs_malloc.c
Go to the documentation of this file.
1 #include "cs.h"
2 #ifdef MATLAB_MEX_FILE
3 #define malloc mxMalloc
4 #define free mxFree
5 #define realloc mxRealloc
6 #define calloc mxCalloc
7 #endif
8 
9 /* wrapper for malloc */
10 void *cs_malloc (int n, size_t size)
11 {
12  return (malloc (CS_MAX (n,1) * size)) ;
13 }
14 
15 /* wrapper for calloc */
16 void *cs_calloc (int n, size_t size)
17 {
18  return (calloc (CS_MAX (n,1), size)) ;
19 }
20 
21 /* wrapper for free */
22 void *cs_free (void *p)
23 {
24  if (p) free (p) ; /* free p if it is not already NULL */
25  return (NULL) ; /* return NULL to simplify the use of cs_free */
26 }
27 
28 /* wrapper for realloc */
29 void *cs_realloc (void *p, int n, size_t size, int *ok)
30 {
31  void *pnew ;
32  pnew = realloc (p, CS_MAX (n,1) * size) ; /* realloc the block */
33  *ok = (pnew != NULL) ; /* realloc fails if pnew is NULL */
34  return ((*ok) ? pnew : p) ; /* return original p if failure */
35 }
void * cs_free(void *p)
Definition: cs_malloc.c:22
void * cs_realloc(void *p, int n, size_t size, int *ok)
Definition: cs_malloc.c:29
void * cs_calloc(int n, size_t size)
Definition: cs_malloc.c:16
#define CS_MAX(a, b)
Definition: cs.h:134
void * cs_malloc(int n, size_t size)
Definition: cs_malloc.c:10


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:31