Mail Archives: djgpp-workers/1998/01/14/09:15:12
DJ,
According to the documentation (libc.inf),
`free(NULL);' should do nothing. But, with
DJGPP V2.02 alpha 980101 it crashes. Also,
realloc needs special treatment for `NULL'.
I noticed many programs/libs rely on this
behaviour (Allegro, LWP, etc).
I know, `malloc()', `free()' and `realloc()'
are new. Just thought I'd let you know.
I suggest (don't take this too seriously,
I'm not an expert on this) this diff:
*** malloc.c Fri Jan 2 01:04:46 1998
--- mdrmallo.c Sun Jan 11 22:59:52 1998
***************
*** 278,284 ****
{
int b;
BLOCK *block = (BLOCK *)((char *)ptr-4);
!
#if NUMSMALL
if (block->size < SMALL)
{
--- 278,285 ----
{
int b;
BLOCK *block = (BLOCK *)((char *)ptr-4);
! if (ptr == NULL)
! return;
#if NUMSMALL
if (block->size < SMALL)
{
***************
*** 324,330 ****
{
BLOCK *b = (BLOCK *)((char *)ptr-4);
char *newptr;
! int copysize = b->size;
if (size <= b->size)
{
#if 0
--- 325,334 ----
{
BLOCK *b = (BLOCK *)((char *)ptr-4);
char *newptr;
! int copysize;
! if (ptr == NULL)
! return (char *)malloc(size);
! copysize = b->size;
if (size <= b->size)
{
#if 0
--
Groeten, Michel. http://www.cs.vu.nl/~mdruiter
\----/==\----/
\ / \ / "You know, Beavis, you need things that suck,
\/ \/ to have things that are cool", Butt-Head.
- Raw text -