Mail Archives: djgpp/1994/05/11/20:16:36
It's not just non-trivial, it's impossible if you think about it. malloc()
has no way of knowing what its caller does with the pointer it returns - it
could even write it to a file which it reads later in the program if
it wanted to be perverse. It is never permissible to move around malloc'ed
You may be right in general. But I'd like to point out that DOS is a
program and this is *exactly* what a memory manager does for DOS (or
any OS), otherwise you'd have to reboot after every program, and
multitasking would be impossible (on a continuing basis; your idea of
malloc is that it is simply a memory leak).
blocks once they have been allocated. The only thing you could hope to do is
If it's been free()'d the memory manager can assume it's not being
used, and take it away. Under protected mode, this should be
implementable in such a way as to result in an access error.
to free memory at the end of your address space when possible, or chunks in
the middle if they are on memory allocation boundaries and the memory
allocation system (I'm speaking generally here, not just about DOS)
lets you do that.
David Ronis is talking about *huge* (not MS C "huge" :) blocks of
memory, ceratinly including blocks that could theoretically be
returned, even by your standard. I am fuzzy on the details, but isn't
it true that protected memory is effectively addressed via handles
(implemented in hardware), and there fore you could resize blocks on
the fly? (By copying to a smaller block and resetting the handle.)
This might not be worthwhile in general, or too dangerous, but in fact
memory managers do it. (Then they enforce strict rules about usage by
clients.) David might find it useful to write his own alloc which
gets VCPI or DPMI memory (since he's running under DV/X, these are
available), not "GO32 memory". This might cost him virtual memory,
depending on the implementation.
------------------------------------------------------------------------------
Kevin Ashley K DOT Ashley AT Ulcc DOT ac DOT uk
Systems Development Group Manager ...ukc!ncdlab!K.Ashley
University of London Computer Centre.
+-----------------------------------------------------------------------+
| Stephen Turnbull |
| University of Tsukuba, Institute of Socio-Economic Planning |
| Tennodai 1-chome 1--1, Tsukuba, Ibaraki 305 JAPAN |
| Phone: +81 (298) 53-5091 Fax: +81 (298) 55-3849 |
| Email: turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp |
| |
| Founder and CEO, Skinny Boy Associates |
| Mechanism Design and Social Engineering |
| REAL solutions to REAL problems of REAL people in REAL time! REALLY. |
| Phone: +81 (298) 56-2703 |
+-----------------------------------------------------------------------+
- Raw text -