get size of malloc'd object

Ed Patriquin ed at valid.UUCP
Sat Jun 14 06:30:37 AEST 1986


> Xref: pesnta net.unix:21451 net.unix-wizards:22133 net.arch:21118 net.lang.c:21930
> 
> 
> 	I have a need in my application to find the size of a
> 	previously malloc'd object (maybe an array or structure).
> 	Also, this other routine has no idea about the structure 
>	of this area and doesn't even care.  Now, the question, 
>	how can this other routine get the size of the area pointed
>	to by passed pointer.
> 		NAME:	Michael Umansky (misha)
> 			Daisy Systems Corp.

	Well in UNIX(TM) one could write their own memory allocator
	and include a chunksize (ptr) function,  I don't know how you
	would do it in DNIX(TM).  But really, why not establish a protocol
	between the offending functions.  Since some function somewhere
	knows how big the chunk is, create a data structure which contains
	the information and make it available to the rest of the program.
	
	It is really hard to come up which general purpose algorithmic 
	solutions to problems without having even a glimmer of what
	environment you are talking about, i.e. passing around display
	lists, or strings or matrix inversion.
-- 

	IRS:	Ed Patriquin
	USENET:	...!ucbvax!hplabs!pesnta!valid!ed
	USPS:	Valid Logic, 2820 Orchard Parkway, San Jose, Calif 95134
	ATT:	(408) 945-9400

This disclaimer is to disclaim any knowledge of a disclaimer.



More information about the Comp.unix mailing list