From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: allocated memory size Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: References: <8gbas1$c2b$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 33 X-Trace: /bV2/76Fu+Iy00qXtnIeGJv+Lb5vEoFfCV6mr2LOuKEPMuHZuwFEfYAKXOQg9ud7jSC8RpepA3yA!BpR+H6FTyJZF0K01NMDQsKhrDA+2JDGtV0P39pxGMJZyv+knf5qv5hTFoEecdfaGdOug/V1OjI7g!LtG0zbA= X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Tue, 23 May 2000 03:01:12 GMT Distribution: world Date: Tue, 23 May 2000 03:01:12 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On 22 May 2000 12:57:37 GMT, Hans-Bernhard Broeker wrote: >Kalum Somaratna aka Grendel wrote: >[...] >> Actually Why would you need to know how much of bytes has been allocated >> to a pointer... > >In a nutshell: dynmically sized arrays. > >What a C++ programmer would implement using the 'vector<>' template >can be implemented in C by a data structure containing a pointer to >allocated memory, plus two variables: one to hold the current size of >that array, and another that tells up to which place the array is >currently filled. // NOT ANSI C!!! // This is GNU C and perhaps C99. It uses zero-size arrays. typedef struct vector_int { int _sizeInMem; // the current size of the array in core int _numElems; // up to which place the array is currently filled int v[0]; // the data } vector_int; -- Damian Yerrick "I refuse to listen to those who refuse to listen to reason." See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your signature to prevent the spread of signature viruses. http://www.mcafee.com/