]> git.pld-linux.org Git - packages/busybox.git/blob - busybox-malloc.patch
- add initial support for amd64
[packages/busybox.git] / busybox-malloc.patch
1 Only in busybox-0.60.1+/libbb: tags
2 diff -ur busybox-0.60.1/libbb/xfuncs.c busybox-0.60.1+/libbb/xfuncs.c
3 --- busybox-0.60.1/libbb/xfuncs.c       Thu Jun 28 23:22:19 2001
4 +++ busybox-0.60.1+/libbb/xfuncs.c      Sun Oct 28 15:56:08 2001
5 @@ -35,7 +35,12 @@
6  #ifndef DMALLOC
7  extern void *xmalloc(size_t size)
8  {
9 -       void *ptr = malloc(size);
10 +       void *ptr;
11 +
12 +       if (size == 0)
13 +               size++;
14 +               
15 +       ptr = malloc(size);
16  
17         if (!ptr)
18                 error_msg_and_die(memory_exhausted);
19 @@ -54,6 +59,9 @@
20                 return NULL;
21         }
22  
23 +       if (size == 0)
24 +               size++;
25 +
26         ptr = realloc(old, size);
27         if (!ptr)
28                 error_msg_and_die(memory_exhausted);
29 @@ -62,9 +70,18 @@
30  
31  extern void *xcalloc(size_t nmemb, size_t size)
32  {
33 -       void *ptr = calloc(nmemb, size);
34 +       void *ptr;
35 +       
36 +       if (nmemb == 0)
37 +               nmemb++;
38 +               
39 +       if (size == 0)
40 +               size++;
41 +               
42 +       ptr = calloc(nmemb, size);
43         if (!ptr)
44                 error_msg_and_die(memory_exhausted);
45 +               
46         return ptr;
47  }
48  
This page took 0.029603 seconds and 3 git commands to generate.