About C strokes and pointers ...
Yesterday I wrote the following code (try Remember some parts of my memory):
typedef struct {signed small int iFrames; Unsigned short full * iTime; // array with elements [0 .. x] holding time for each frame} tile; Tile * loadtile (four * sFile) {// expects to have enough space for a complete tile structure, from which the base memory address is stored in the tmpResult pointer tile * tmpResult = malloc (sizeof (tile)) ; // There are things that determine the value of the tile unit // ... // return the indicator for return for more use tmpResult; } Zero main () {// defines a tile indicator and its value sets the returned indicator (this should also be allowed in one line) // expected to get the value of the // indicator - that is the base memory address where The malloc has been built on the available tile * tmpTile; TmpTile = loadTile ("tile1.dat"); // // found / set element of tile // // free tile-free (TMPT); }What I'm looking for: I use the malloced tile structure inside a cÃÆ'à ¢ â,¬Å¡Ãƒâ € šÃ, ©, but once I use it in the main Trying to use, I get an error about Stack from Visual Studio (which tells me that something is released after the call).
If I change this, then I give the malloc position in the main, and pass the pointers to the locale function as an argument (so that the function no longer returns anything) So it works, but I believe that I should be able to place the Lodalable function to Molok and correct a pointer at that place ?!
Thank you !!
There is nothing wrong with whatever you are trying to do, or code here Not less than However, I am worried about this line:
unsigned short int * iTime; / />
This element is not true until you are mapping iTime somewhere : / P>
tile * tmpResult = malloc (sizeof (tile)); TMPResult-> ITime = malloc (size (small) * n);
When you clean, you have to clear it:
Free (tmpTile-> iTime); Free (tmpTile);
Comments
Post a Comment