www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/05/00:41:59

Sender: nate AT cartsys DOT com
Message-ID: <36DF6DB5.D8A4E101@cartsys.com>
Date: Thu, 04 Mar 1999 21:37:57 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: how to know the size of allocated memory
References: <Pine DOT SV4 DOT 3 DOT 93 DOT 990304205056 DOT 29767A-100000 AT tagore>
Reply-To: djgpp AT delorie DOT com

Raju K.V wrote:
> 
> hi,
> 
> I have written a library say libxx.a. Suppose we have a function yy()
> which takes a char * as argument. In the user application, the user
> allocates some memory using malloc and passes the pointer to the allocated
> memory  as arguement to yy(). The previous implementation of function was
> very simple. But a new requirement is to check the amount of memory that
> the user has allocated. Is there any way by which I can find the length of
> the allocated memory block, given a pointer to the block?
> I dont want to change the user interface. The user should not be aware of
> the change in the implementation of function yy().

Not with any portability whatever.  You may be able to poke around in
the internals of the heap (for which UTSL), but don't expect it to work
for any future or past release of DJGPP.  If you want to know the size
of the block, you'll really have to get the user to pass it.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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