Go to the documentation of this file. 10 #ifndef _GK_MKMEMORY_H_ 11 #define _GK_MKMEMORY_H_ 14 #define GK_MKALLOC(PRFX, TYPE)\ 18 TYPE *PRFX ## malloc(size_t n, char *msg)\ 20 return (TYPE *)gk_malloc(sizeof(TYPE)*n, msg);\ 27 TYPE *PRFX ## realloc(TYPE *ptr, size_t n, char *msg)\ 29 return (TYPE *)gk_realloc((void *)ptr, sizeof(TYPE)*n, msg);\ 36 TYPE *PRFX ## smalloc(size_t n, TYPE ival, char *msg)\ 40 ptr = (TYPE *)gk_malloc(sizeof(TYPE)*n, msg);\ 44 return PRFX ## set(n, ival, ptr); \ 51 TYPE *PRFX ## set(size_t n, TYPE val, TYPE *x)\ 65 TYPE *PRFX ## copy(size_t n, TYPE *a, TYPE *b)\ 67 return (TYPE *)memmove((void *)b, (void *)a, sizeof(TYPE)*n);\ 74 TYPE **PRFX ## AllocMatrix(size_t ndim1, size_t ndim2, TYPE value, char *errmsg)\ 79 matrix = (TYPE **)gk_malloc(ndim1*sizeof(TYPE *), errmsg);\ 83 for (i=0; i<ndim1; i++) { \ 84 matrix[i] = PRFX ## smalloc(ndim2, value, errmsg);\ 85 if (matrix[i] == NULL) { \ 87 gk_free((void **)&matrix[j], LTERM); \ 99 void PRFX ## FreeMatrix(TYPE ***r_matrix, size_t ndim1, size_t ndim2)\ 104 if (*r_matrix == NULL) \ 109 for (i=0; i<ndim1; i++) \ 110 gk_free((void **)&(matrix[i]), LTERM);\ 112 gk_free((void **)r_matrix, LTERM);\ 119 void PRFX ## SetMatrix(TYPE **matrix, size_t ndim1, size_t ndim2, TYPE value)\ 123 for (i=0; i<ndim1; i++) {\ 124 for (j=0; j<ndim2; j++)\ 125 matrix[i][j] = value;\ 130 #define GK_MKALLOC_PROTO(PRFX, TYPE)\ 131 TYPE *PRFX ## malloc(size_t n, char *msg);\ 132 TYPE *PRFX ## realloc(TYPE *ptr, size_t n, char *msg);\ 133 TYPE *PRFX ## smalloc(size_t n, TYPE ival, char *msg);\ 134 TYPE *PRFX ## set(size_t n, TYPE val, TYPE *x);\ 135 TYPE *PRFX ## copy(size_t n, TYPE *a, TYPE *b);\ 136 TYPE **PRFX ## AllocMatrix(size_t ndim1, size_t ndim2, TYPE value, char *errmsg);\ 137 void PRFX ## FreeMatrix(TYPE ***r_matrix, size_t ndim1, size_t ndim2);\ 138 void PRFX ## SetMatrix(TYPE **matrix, size_t ndim1, size_t ndim2, TYPE value);\
gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:18