]> git.pld-linux.org Git - packages/glibc.git/blob - glibc-malloc.patch
- rel 3; malloc updates that fix locale generation problems
[packages/glibc.git] / glibc-malloc.patch
1 Index: Makefile
2 ===================================================================
3 RCS file: /cvs/glibc/libc/malloc/Makefile,v
4 retrieving revision 1.54
5 retrieving revision 1.55
6 diff -u -r1.54 -r1.55
7 --- glibc/malloc/Makefile       7 May 2007 15:30:57 -0000       1.54
8 +++ glibc/malloc/Makefile       21 May 2007 16:12:25 -0000      1.55
9 @@ -104,7 +104,6 @@
10  include ../Rules
11  
12  CFLAGS-mcheck-init.c = $(PIC-ccflag)
13 -CFLAGS-malloc.c += -DMALLOC_DEBUG
14  
15  $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
16         -rm -f $@
17 Index: arena.c
18 ===================================================================
19 RCS file: /cvs/glibc/libc/malloc/arena.c,v
20 retrieving revision 1.27
21 retrieving revision 1.28
22 diff -u -r1.27 -r1.28
23 --- glibc/malloc/arena.c        13 May 2007 20:32:57 -0000      1.27
24 +++ glibc/malloc/arena.c        21 May 2007 16:13:07 -0000      1.28
25 @@ -370,9 +370,6 @@
26    mp_.top_pad        = DEFAULT_TOP_PAD;
27  #endif
28    mp_.n_mmaps_max    = DEFAULT_MMAP_MAX;
29 -#if MALLOC_DEBUG
30 -  mp_.n_mmaps_cmax   = DEFAULT_MMAP_MAX;
31 -#endif
32    mp_.mmap_threshold = DEFAULT_MMAP_THRESHOLD;
33    mp_.trim_threshold = DEFAULT_TRIM_THRESHOLD;
34    mp_.pagesize       = malloc_getpagesize;
35 Index: hooks.c
36 ===================================================================
37 RCS file: /cvs/glibc/libc/malloc/hooks.c,v
38 retrieving revision 1.21
39 retrieving revision 1.22
40 diff -u -r1.21 -r1.22
41 --- glibc/malloc/hooks.c        13 May 2007 20:32:57 -0000      1.21
42 +++ glibc/malloc/hooks.c        21 May 2007 16:12:12 -0000      1.22
43 @@ -496,7 +496,7 @@
44     then the hooks are reset to 0.  */
45  
46  #define MALLOC_STATE_MAGIC   0x444c4541l
47 -#define MALLOC_STATE_VERSION (0*0x100l + 2l) /* major*0x100 + minor */
48 +#define MALLOC_STATE_VERSION (0*0x100l + 3l) /* major*0x100 + minor */
49  
50  struct malloc_save_state {
51    long          magic;
52 @@ -507,9 +507,6 @@
53    unsigned long trim_threshold;
54    unsigned long top_pad;
55    unsigned int  n_mmaps_max;
56 -#if MALLOC_DEBUG
57 -  unsigned int  n_mmaps_cmax;
58 -#endif
59    unsigned long mmap_threshold;
60    int           check_action;
61    unsigned long max_sbrked_mem;
62 @@ -553,9 +550,6 @@
63    ms->trim_threshold = mp_.trim_threshold;
64    ms->top_pad = mp_.top_pad;
65    ms->n_mmaps_max = mp_.n_mmaps_max;
66 -#if MALLOC_DEBUG
67 -  ms->n_mmaps_cmax = mp_.n_mmaps_cmax;
68 -#endif
69    ms->mmap_threshold = mp_.mmap_threshold;
70    ms->check_action = check_action;
71    ms->max_sbrked_mem = main_arena.max_system_mem;
72 @@ -601,8 +595,9 @@
73        assert(ms->av[2*i+3] == 0);
74        first(b) = last(b) = b;
75      } else {
76 -      if(i<NSMALLBINS || (largebin_index(chunksize(ms->av[2*i+2]))==i &&
77 -                         largebin_index(chunksize(ms->av[2*i+3]))==i)) {
78 +      if(ms->version >= 3 &&
79 +        (i<NSMALLBINS || (largebin_index(chunksize(ms->av[2*i+2]))==i &&
80 +                          largebin_index(chunksize(ms->av[2*i+3]))==i))) {
81         first(b) = ms->av[2*i+2];
82         last(b) = ms->av[2*i+3];
83         /* Make sure the links to the bins within the heap are correct.  */
84 @@ -622,14 +617,22 @@
85        }
86      }
87    }
88 +  if (ms->version < 3) {
89 +    /* Clear fd_nextsize and bk_nextsize fields.  */
90 +    b = unsorted_chunks(&main_arena)->fd;
91 +    while (b != unsorted_chunks(&main_arena)) {
92 +      if (!in_smallbin_range(chunksize(b))) {
93 +       b->fd_nextsize = NULL;
94 +       b->bk_nextsize = NULL;
95 +      }
96 +      b = b->fd;
97 +    }
98 +  }
99    mp_.sbrk_base = ms->sbrk_base;
100    main_arena.system_mem = ms->sbrked_mem_bytes;
101    mp_.trim_threshold = ms->trim_threshold;
102    mp_.top_pad = ms->top_pad;
103    mp_.n_mmaps_max = ms->n_mmaps_max;
104 -#if MALLOC_DEBUG
105 -  mp_.n_mmaps_cmax = ms->n_mmaps_cmax;
106 -#endif
107    mp_.mmap_threshold = ms->mmap_threshold;
108    check_action = ms->check_action;
109    main_arena.max_system_mem = ms->max_sbrked_mem;
110 Index: malloc.c
111 ===================================================================
112 RCS file: /cvs/glibc/libc/malloc/malloc.c,v
113 retrieving revision 1.178
114 retrieving revision 1.180
115 diff -u -r1.178 -r1.180
116 --- glibc/malloc/malloc.c       15 May 2007 01:51:17 -0000      1.178
117 +++ glibc/malloc/malloc.c       21 May 2007 16:12:53 -0000      1.180
118 @@ -2358,9 +2358,6 @@
119    /* Memory map support */
120    int              n_mmaps;
121    int              n_mmaps_max;
122 -#if MALLOC_DEBUG
123 -  int              n_mmaps_cmax;
124 -#endif
125    int              max_n_mmaps;
126    /* the mmap_threshold is dynamic, until the user sets
127       it manually, at which point we need to disable any
128 @@ -2572,7 +2569,7 @@
129  #if HAVE_MMAP
130      /* address is outside main heap  */
131      if (contiguous(av) && av->top != initial_top(av)) {
132 -      assert(((char*)p) < min_address || ((char*)p) > max_address);
133 +      assert(((char*)p) < min_address || ((char*)p) >= max_address);
134      }
135      /* chunk is page-aligned */
136      assert(((p->prev_size + sz) & (mp_.pagesize-1)) == 0);
137 @@ -2876,8 +2873,6 @@
138    assert(total <= (unsigned long)(mp_.max_total_mem));
139    assert(mp_.n_mmaps >= 0);
140  #endif
141 -  assert(mp_.n_mmaps <= mp_.n_mmaps_cmax);
142 -  assert(mp_.n_mmaps_max <= mp_.n_mmaps_cmax);
143    assert(mp_.n_mmaps <= mp_.max_n_mmaps);
144  
145    assert((unsigned long)(av->system_mem) <=
146 @@ -3475,13 +3470,6 @@
147      }
148  
149    mp_.n_mmaps--;
150 -#if MALLOC_DEBUG
151 -  if (mp_.n_mmaps_cmax > mp_.n_mmaps_max)
152 -    {
153 -      assert (mp_.n_mmaps_cmax == mp_.n_mmaps + 1);
154 -      mp_.n_mmaps_cmax = mp_.n_mmaps;
155 -    }
156 -#endif
157    mp_.mmapped_mem -= total_size;
158  
159    int ret __attribute__ ((unused)) = munmap((char *)block, total_size);
160 @@ -5397,9 +5385,6 @@
161    mp_.n_mmaps_max = 0;
162    mem = _int_malloc(av, size);
163    mp_.n_mmaps_max = mmx;   /* reset mmap */
164 -#if MALLOC_DEBUG
165 -  mp_.n_mmaps_cmax = mmx;
166 -#endif
167    if (mem == 0)
168      return 0;
169  
170 @@ -5725,17 +5710,8 @@
171        res = 0;
172      else
173  #endif
174 -      {
175 -#if MALLOC_DEBUG
176 -       if (mp_.n_mmaps <= value)
177 -         mp_.n_mmaps_cmax = value;
178 -       else
179 -         mp_.n_mmaps_cmax = mp_.n_mmaps;
180 -#endif
181 -
182 -       mp_.n_mmaps_max = value;
183 -       mp_.no_dyn_threshold = 1;
184 -      }
185 +      mp_.n_mmaps_max = value;
186 +      mp_.no_dyn_threshold = 1;
187      break;
188  
189    case M_CHECK_ACTION:
190 Index: mcheck.c
191 ===================================================================
192 RCS file: /cvs/glibc/libc/malloc/mcheck.c,v
193 retrieving revision 1.18
194 retrieving revision 1.20
195 diff -u -r1.18 -r1.20
196 --- glibc/malloc/mcheck.c       8 Sep 2004 20:36:02 -0000       1.18
197 +++ glibc/malloc/mcheck.c       19 May 2007 04:27:20 -0000      1.20
198 @@ -1,5 +1,5 @@
199  /* Standard debugging hooks for `malloc'.
200 -   Copyright (C) 1990-1997,99,2000,01,02 Free Software Foundation, Inc.
201 +   Copyright (C) 1990-1997,1999,2000-2002,2007 Free Software Foundation, Inc.
202     This file is part of the GNU C Library.
203     Written May 1989 by Mike Haertel.
204  
205 @@ -264,6 +264,12 @@
206  static __ptr_t
207  reallochook (__ptr_t ptr, __malloc_size_t size, const __ptr_t caller)
208  {
209 +  if (size == 0)
210 +    {
211 +      freehook (ptr, caller);
212 +      return NULL;
213 +    }
214 +
215    struct hdr *hdr;
216    __malloc_size_t osize;
217  
This page took 0.043149 seconds and 3 git commands to generate.