Subj : Re: Pointers + Stuff To : borland.public.cpp.borlandcpp From : Alistair Date : Sun Jul 04 2004 05:46 pm Hi, forget it. This works just like I have written, I just had a silly bug in my program that was causing an error. I wasnt setting the somethings[x] = NULL when i had finished with the reference inside (the one I cleaned up). "Alistair" wrote in message news:40e81d55$1@newsgroups.borland.com... > Hi, > > I am just learning out pointers and was trying to manage assigned memory: > > struct s_Something > { > void *data; > int length; > int datatype; //0 - image, 1 - wav, 2 - string, 3 - etc... > bool temp; > }; > > I can happily use this, e.g. > > s_Something mySomething; > > mySomething.data = malloc(80); > mySomething.length = 80; > > then use it like > > dosummet(&mySomething); > //in dosummet -> mySomething->data etc... > > Now, I create a few of these through out my app and it works fine, but here > is where i am stuck. I want to create a pointer list, if its possible, e.g. > > s_Something *somethings[256]; > > and each something is a pointer to an object I have created like above. The > reason is that I can then > loop the somethings and free(mySomthingx.data). > > I only want the list for storing references to the objects so i can free > them. I then pass the objects via pointers through functions etc to be > used. > > so at the end of my main application loop I can loop the list of pointers, > getting the objects using memory and then see if they are temp (temporary) > and if so, i can free the memory. > > Can someone give me some idea how this can be done without a lot of > technical speak, I am new to C++ and I would like to get an understanding > without long words / phrases i dont yet understand! > > Thanks > > Alistair > > .