avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Bug in avr-libc malloc()?


From: Geoffrey Wossum
Subject: [avr-gcc-list] Bug in avr-libc malloc()?
Date: Fri, 3 Jan 2003 13:37:19 -0600

Hi all,

I believe I've found in bug that exists in the malloc() implementation in the 
snapshots from 17dec2002 and 04nov2002.

Here's (basically) the code I'm running:

        char *ptrs[32];
        __malloc_heap_start = 0x8000;
        __malloc_heap_end = 0xFFFF;
        for (j = 0; j < 32; j++) {
                ptrs[j] = (char *)malloc(1024);
                /* output j and ptrs[j] to serial port */
        }

I would expect the last malloc() to return NULL, since there's not 1024 bytes 
left in the heap.  Instead, I get the following output:

0 = 00008002
1 = 00008404
2 = 00008806
-cut-
29 = 0000f43c
30 = 0000f83e
31 = 0000fc40

The last malloc() returns a chunk of memory that is only 959 bytes before the 
end of the heap!

Am I doing something wrong, or is this a bug?

---
Geoffrey Wossum
Project AKO - http://ako.sf.net

avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]