>> > Is the management of such flags a part of the standard
>> > C library already?
>> > http://en.wikipedia.org/wiki/Malloc
>>
>> No. The Standard recognizes the possibility that some
>> memory may be read-only, but does not require the capability
>> and provides no way to control it. Fancier attributes like
>> "okay to forget the content" or "likely to be used sequentially"
>> are not even dreamt of; they fall under the general heading of
>> platform-specific optimizations.
>
>Are there any chances that this kind of functionality can be added to
>the standard API?
About the only way to make this kind of functionality *USABLE* is to
provide a method of allocating memory which does not share a memory
page with any other allocated memory, where "memory page" is defined
as the minimum granularity for which attributes like "writable" and
"executable" can act. For i386 architecture, that is 4K bytes (or
sometimes 4M bytes) at the hardware level. Otherwise, when you
change the attributes of one piece of memory, you may alter the
attributes of others unexpectedly, and that makes use of the features
so unpredictable that they are useless.
Another possible approach would be to define "pools" of memory.
Any memory in a "pool" has the same attributes as other memory in
the same "pool", so you change the attributes of everything in a
pool all at once. Internally, no pool would share memory pages
with another pool. Then you allocate memory out of specific pools
with a new function like malloc() that takes a pool as a second
argument. This is perhaps not quite so wasteful as putting every
allocation in its own page.
Gordon L. Burditt