home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!charnel!sifon!vugranam
- From: vugranam@pike.ee.mcgill.ca (Vugranam Chakravarthy Sreedhar)
- Newsgroups: comp.lang.c
- Subject: Memory Info.
- Message-ID: <1992Nov20.130913.20148@sifon.cc.mcgill.ca>
- Date: 20 Nov 92 13:09:13 GMT
- Sender: news@sifon.cc.mcgill.ca
- Organization: McGill University - VLSI Laboratory, Montreal, CANADA.
- Lines: 29
- Nntp-Posting-Host: kirk.ee.mcgill.ca
-
-
- Given a pointer to a object that has been previously allocated using
- one of the allocation routine, how can I get the
- size of the object.
-
- For example,
-
- char *c;
- long x ;
-
- c = (char *) malloc (100) ;
- .
- .
- .
-
- x = mem_size(c) ; /* x is block size of c, which in this case is 100 */
-
-
- I want to use this to keep track of memory statistics. Now what I do is
- to pass the size to my memory routines. Like
-
- int *mymalloc(size) ; /* this is easy */
-
- int myfree(char *, long size) /* I don't like this !!*/
-
- Thanks
-
-
- Sreedhar
-