Another malloc question

Richard H. Gumpertz rhg at cpsolv.UUCP
Tue Oct 24 06:35:44 AEST 1989


Another question about malloc:

Suppose a system has one data type that must be aligned on a 32-byte boundary
but all other objects can be aligned on a 2-byte boundary.  Suppose further
that the one data type having 32-byte alignment requirements has size X.
Clearly no call to malloc requesting fewer than X bytes can really need 32-byte
alignment; if there wre need of a 32-byte alignment then the size would have
to be at least X.

The current standard seems to prohibit malloc from special-casing requests
for less than size X and returning only even alignment.  Is this overkill in
the language of the standard?  Wouldn't it be better for the standard to only
require malloc(N) to align the return value sufficiently for all objects
of size <= N?  This might let small requests pack more efficiently without
breaking any programs.
-- 
==========================================================================
| Richard H. Gumpertz   rhg at cpsolv.UUCP -or- ...!uunet!amgraf!cpsolv!rhg |
| Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749 |
==========================================================================



More information about the Comp.lang.c mailing list