Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. memory allocation

memory allocation

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gerald Mercet
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • G Gerald Mercet

      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

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      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 ) ;

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups