www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/22/21:16:07

Message-ID: <358EFF0A.3800AC93@ipass.net>
From: Terry <iceman AT ipass DOT net>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Deleting mem allocated to dynamic array?
References: <6mmd9s$o7f AT bgtnsc03 DOT worldnet DOT att DOT net>
Lines: 23
Date: Tue, 23 Jun 1998 01:09:25 GMT
NNTP-Posting-Host: ts2-102-ppp.ipass.net
NNTP-Posting-Date: Mon, 22 Jun 1998 21:09:25 EDT
Organization: iPass.Net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jeff W. wrote:
> 
> I declared an array like this:
> 
> MapStruct **Tiles
> 
> and allocated memory to it like this:
> 
> Tiles = new MapStruct *[XSize];
>  for (int i = 0; i < XSize; i++)
>     Tiles[i] = new MapStruct[YSize];
> 
> XSize and YSize being the width and height of the map.  My question
> is, how do I delete the memory I allocated to this array?  Thanks.
> 

Should be something like:

   for (i=0;i<XSize; i++)
        delete Tiles[i];
   delete Tiles;

Terry

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019