www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/20/08:30:20

From: Chris Mears <cmears AT bigpond DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: allocated memory size
Organization: only if absoultely necessary
Message-ID: <0c0dis0brlemhqhikei7d46sndbsvu9drd@4ax.com>
References: <200005190942 DOT LAA19117 AT acp3bf DOT physik DOT rwth-aachen DOT de> <Pine DOT LNX DOT 4 DOT 10 DOT 10005200546470 DOT 2249-100000 AT roadrunner DOT grendel DOT net>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Lines: 36
Date: Sat, 20 May 2000 22:16:02 +1000
NNTP-Posting-Host: 203.54.71.170
X-Trace: newsfeeds.bigpond.com 958824514 203.54.71.170 (Sat, 20 May 2000 22:08:34 EST)
NNTP-Posting-Date: Sat, 20 May 2000 22:08:34 EST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sat, 20 May 2000 05:47:31 +0600 (LKT), that hoopy frood Kalum
Somaratna aka Grendel wrote:

>On Fri, 19 May 2000, Hans-Bernhard Broeker wrote:
>
>> In article <39249FAE DOT F0428E1F AT fujixerox DOT co DOT jp> you wrote:
>> > I am sorry if my question are too silly. I am absolute novice at
>> > programming in C and that is the reason for the question.
>> 
>> > Problem: 
>> > Is there any way I can find out the number of bytes of memory that has 
>> > been allocated to a pointer. 
>> 
>> None that would be reliable. If you think you need that information,
>> you'll have to keep track of it yourself.
>
>Actually Why would you need to know how much of bytes has been allocated
>to a pointer...

Perhaps so that you don't overrun an array's bounds.  For example:

void fill(int *array, size_t elem)
{
        size_t i;

        for (i = 0 ; i < elem ; i++) {
                array[i] = i;
        }
}

In this case you need to know the amount of storage that the array has
been allocated.

-- 
Chris Mears
ICQ: 36697123

- Raw text -


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