From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10924 invoked by alias); 31 Oct 2002 10:52:35 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 10730 invoked from network); 31 Oct 2002 10:52:31 -0000 Received: from unknown (HELO deeproot.co.in) (202.71.150.112) by sources.redhat.com with SMTP; 31 Oct 2002 10:52:31 -0000 Received: (qmail 11374 invoked from network); 31 Oct 2002 16:05:35 -0000 Received: from unknown (HELO 172.16.1.5) (info@deeproot.co.in@202.62.83.74) by 0 with SMTP; 31 Oct 2002 16:05:35 -0000 Received: (qmail 25775 invoked by uid 0); 31 Oct 2002 10:30:45 -0000 Received: from unknown (HELO localhost) (127.0.0.1) by 0 with SMTP; 31 Oct 2002 10:30:45 -0000 Date: Thu, 31 Oct 2002 02:52:00 -0000 From: Arunachalam G X-X-Sender: arunachalam@anubhav.lan.deeproot.co.in To: Eljay Love-Jensen cc: "gcc-help@gcc.gnu.org" Subject: Re: why there is no memlen(); In-Reply-To: <4.3.2.7.2.20021030082146.036212e8@iplan-mn.corp.adobe.com> Message-ID: References: <4.3.2.7.2.20021030082146.036212e8@iplan-mn.corp.adobe.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-10/txt/msg00384.txt.bz2 Hi, > > Depends entirely on your heap manager. > > For example, one platform that I worked on, you could do this: > > typedef unsigned char byte; > struct MemChunk { > unsigned long length; // 32-bit > byte data[1]; // stretchy buffer > }; > Its very tricky way to get the allocated memory length. Never knew this. Thanks. What is that? going 4 bytes back & reading it give the amount of memory allocated. does it contains the attributes of the data type. and why it is compiler specific? I use gcc 2.95.4 on linux in IA32. The above code gave some more addtional length than the actually allocated. (for 100 bytes it gave 105 & for 1000 it gave 1009). Is it due to alignment? thanks, arun.