To find out the names of open files in a process
Brett Galloway
brett at wjvax.UUCP
Mon Feb 1 10:00:45 AEST 1988
In article <2672 at bloom-beacon.MIT.EDU> eichin at athena.mit.edu (Mark W. Eichin) writes:
>>[why isn't there an msize() routine that returns the actual amount of space
>>allocated by malloc()?]
>In summary: there IS a reason that there isn't an msize() by default,
>it is a constraint upon the allocator which can be overly restrictive
>in certain usage patterns.
I posted the other day another reason for making such a feature (a feature
to return the *actual* malloc()'d size available to the user) available.
I neglected to mention that I was thinking in terms of a variant malloc()
that returned the actual size as well as the character pointer. I agree that
an after-the-fact msize() routine might be overly expensive. However, it seems
to me that a variant malloc() that reported what it actually allocated could
be had for free. I mean a routine like
char *mallocsize(size,actual)
unsigned size;
unsigned *actual;
(with types ala BSD -- fill in your own types). If the implementor were
lazy, or forgot to implement it at all, he (or you) could just use
char *mallocsize(size,actual)
unsigned size;
unsigned *actual;
{
*actual = size;
return(malloc(size));
}
--
-------------
Brett D. Galloway
{ac6,calma,cerebus,isi,isieng,pyramid,tymix}!wjvax!brett
More information about the Comp.lang.c
mailing list