memory allocation
-
Hi everybody, I would like to create a function which could allocate memory for any of pointer of pointer declared. In my class C, i consider 2 pointers of pointers : **p and **q ( declared as public in class C), i would like to create a function AllocMemPointerOfPointer, which takes 3 input : RowSize, ColSize and Pointer. The function doesn't return value. It just allocate memory for Pointer, which is a pointer on RowSize pointers of any type . How could i do that without allocate memory to a "copy" of Pointer ? I hope my question is clear ! if not, feel free to ask me more informations ! Thanks in advance for your answers Gerald
-
Hi everybody, I would like to create a function which could allocate memory for any of pointer of pointer declared. In my class C, i consider 2 pointers of pointers : **p and **q ( declared as public in class C), i would like to create a function AllocMemPointerOfPointer, which takes 3 input : RowSize, ColSize and Pointer. The function doesn't return value. It just allocate memory for Pointer, which is a pointer on RowSize pointers of any type . How could i do that without allocate memory to a "copy" of Pointer ? I hope my question is clear ! if not, feel free to ask me more informations ! Thanks in advance for your answers Gerald
typedef struct DOUBLE_MATRIX { double **ppdDoubleMatrix; MIINT32 iRows; MIINT32 iColumns; }DOUBLE_MATRIX; static DOUBLE_MATRIX *New(MIINT32 iRows, MIINT32 iColumns) { DOUBLE_MATRIX *pxThis = NULL; pxThis = calloc(1, sizeof(mxSystemDOUBLE_MATRIX)); if (pxThis && iRows > 0 && iColumns > 0) { MIINT32 iRowsCounter = 0; pxThis->iRows = iRows; pxThis->iColumns = iColumns; pxThis->ppdDoubleMatrix = (double **) calloc(iRows, sizeof(double *)); for (iRowsCounter = 0; iRowsCounter < iRows; iRowsCounter++) { pxThis->ppdDoubleMatrix[iRowsCounter] = (double *) calloc(iColumns, sizeof(double)); } } return pxThis; } Papa while (TRUE) Papa.WillLove ( Bebe ) ;