]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/open-amp.git/blob - obsolete/system/generic/machine/zynq7/linux-firmware/src/zlib/sbrk.c
Move func_test_suite to directly under apps/
[processor-sdk/open-amp.git] / obsolete / system / generic / machine / zynq7 / linux-firmware / src / zlib / sbrk.c
2 #define HEAP_SIZE   1024 * 512
4 extern unsigned int _heap_start;
6 static void *heap_end = 0;
7 static int bytes_used = 0;
9 void *_sbrk(int nbytes)
10 {
11         void *prev_heap_end = (void *)-1;       /* Out of heap space */
13         /* Check if it's first call to _sbrk() */
14         if (heap_end == 0) {
15                 heap_end = &_heap_start;
16         }
18         /* Validate request */
19         if (((bytes_used + nbytes) <= HEAP_SIZE)
20             && ((bytes_used + nbytes) >= 0)) {
21                 /* Request is in range, grant it */
22                 prev_heap_end = heap_end;
24                 /* Increment the heap_end pointer and bytes_used */
25                 heap_end += nbytes;
26                 bytes_used += nbytes;
27         }
29         return (prev_heap_end);
30 }
32 void *malloc(int nbytes)
33 {
34         return _sbrk(nbytes);
35 }
37 void free(void *ptr)
38 {
40 }