delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/23/07:30:38

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: allocated memory size
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <ptsjis4i1m77ahpaohvoe0v274533mfj4n@4ax.com>
References: <Pine DOT LNX DOT 4 DOT 10 DOT 10005200546470 DOT 2249-100000 AT roadrunner DOT grendel DOT net> <8gbas1$c2b$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
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
<broeker AT physik DOT rwth-aachen DOT de> wrote:

>Kalum Somaratna aka Grendel <kalum AT lintux DOT cx> 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/

- Raw text -


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