// thus on Fri, 9 Jan 1998 23:08:43 +0100, Erwin virtually wrote: > On Fri, 9 Jan 1998, d. hall wrote: >> void my_free (void *mem) >> { >> #ifdef FREE_IS_BROKEN >> if (mem != NULL) >> #endif >> free (mem); >> >> statistics.mem_alloc -= sizeof (*mem); > You can't take sizeof(void); (that gcc allows you to is a gcc extension). > But anyway, this wouldn't quite do anything useful, since it would give > always the same size back no matter what pointer was passed to the > function. True, considering sizeof (*blah) will normally be 1, architecture independant. I keep forgetting about dereferencing void rules. Well I guess you can use a hash map of referenced addresses. When you malloc you save the address into a hash map with the size, when you free you remove that entry from the hash map. Then again there are several different memory managers, linux has quite a few ported to it, and a couple work well on Solaris. > If you want to do this, you have to do it in the macro: but, as I wrote > before, it will work only pointers to single structures only, not multiple > ones. I thought this was assumed, the only way to get the sizeof of an array is from an array itself. I've been reviewing some of this as far as what they want to do with CX9 (which is looking ugly with it's first draft). d. +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST