From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,6e34f446fe88d4e2,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-03-04 16:56:31 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!gatech!psuvax1!news.cc.swarthmore.edu!netnews.upenn.edu!netaxs.com!cek From: cek@netaxs.com () Newsgroups: comp.unix.osf.osf1 Subject: Number of bytes returned by malloc (or passed to free)? Date: 4 Mar 1995 12:08:33 GMT Organization: Netaxs Message-ID: <3j9l81$lo8@netaxs.com> NNTP-Posting-Host: unix3.netaxs.com X-Newsreader: TIN [version 1.2 PL2] Does anyone know how to determine for OSF/1 on an alpha 3000 how many bytes are actually allocated by malloc? I know this type of code is non-portable and should not be relied upon but I only use it for testing. I use it as a simple check for memory leakage by checking the difference between the total bytes allocated by malloc and the total bytes released by free. I am using OSF/1 V1.3 but will soon be upgrading to OSF/1 V3.2 If anyone is interested, here is the SUN Sparc (4.1.3) version of what I need: In the code below, if memp is the pointer returned by malloc, then size is the number of bytes. #define ALIGNSIZE sizeof (double) typedef struct MEMPTR { unsigned size; unsigned filler; unsigned data [ALIGNSIZE]; } memptr; memptr *q; q = (memptr *) (((char *) memp) - ALIGNSIZE); size = q->size; thanks Chuck