malloc and stuff
Brian W.K. Hook
jdb at reef.cis.ufl.edu
Mon Nov 26 14:32:14 AEST 1990
Small question....how does a C compiler or an operating system (whichever
is responsible) handle "memory fragmentatino". Assume, for instance, that
you allocate 200 1K blocks of memory. Then you free() every other block,
so that you 1K allocated, then 1K not, etc....Now, if all you have is 200K
available to your system, and you allocate now a 100K block (since you
theoretiocally have 100K available), wouldn't pointer arithmetic really
get screwed up? Eg.. *(block2+1) wouldn't return something expected,
would it....or does the C compiler automatically generate code that
compresses memory. But if that is the case, what if you use absolute
addressing? Or would it just say that you can't allocate that 100K block
at all since it isn't contiguous?
More information about the Comp.lang.c
mailing list