Original Post
how does one go about freeing memory taken up by an array of pointers for example:
char* text[4096];
I didn''t dynamically allocate the memory for it, so how do I then free it?
quote:
Original post by element2001
I didn''t dynamically allocate the memory for it, so how do I then free it?

// proper way to select gdi object and to delete it
// so you got something like
HBITMAP myBmp = CreateBitmap();
HDC myDC = CreateCompatibleDC();
HBITMAP = oldBmp;
// save old bitmap handle, otherwise we cant properly delete
// our bitmap
oldBmp = (HBITMAP)SelectObject(myDC, myBmp);
// later on when done with the bitmap and the dc
SelectObject(myDC, oldBmp);
DeleteObject(myBmp);
DeleteDC(myDC);
// if you select mulitple bmps into the dc
// then you only save the first one, since that is the default
// HBITMAP that windows creates/deletes when a HDC is
// created/deleted
for(i=0; i<4096; i++)
{
//if created with malloc
free(text[i]);
// or if new''d
delete text[4096];
}
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more