delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/05/18/10:46:58

Date: Wed, 18 May 94 10:34:27 -0400
From: dj AT ctron DOT com (DJ Delorie)
To: acmq AT alpha DOT coe DOT ufrj DOT br
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: memory allocation details

> * The "_go_dpmi-remaining...memory" functions return values that never 
>   decrease, and so are not equivalent to the usual "coreleft" function.
>   And all are not  very useful because they ignore vacant spaces inside the
>   heap. Am I right?

Correct.

> * Is there some function equivalent to the Borland C "heapwalk", that returns
>   informations about the state of each allocation space in the heap?

No, but you have sources to malloc() so you could write one if you
wanted.

> * What exactly does "malloc"? What is the exact amount of memory necessary for
>   an allocation? How is the structure of the heap? 

libsrc/c/gen/malloc.c, I think (maybe libsrc/c/lib/malloc.c).  I think
it adds four bytes and rounds to a power of two - it's pretty dumb.

> * I am getting garbage when trying to use "memmove" to move the contents of two
>   identical structures allocated with "malloc", one to the other. 
>   The contents of other allocated structures are being corrupted by the
>   operation. The sizes used in "malloc" and "memmove" are the same, and both
>   structures are filled with data, and not only allocated, when the move is
>   done. Some suggestion?

Have you tried memcpy?  If that works and memmove doesn't, there's a
problem.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019