Mercurial > hg > xemacs-beta
comparison src/dynarr.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | 3d6bfa290dbd |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
131 multiplier = 2; | 131 multiplier = 2; |
132 else | 132 else |
133 multiplier = 1.5; | 133 multiplier = 1.5; |
134 | 134 |
135 for (newsize = dy->max; newsize < size;) | 135 for (newsize = dy->max; newsize < size;) |
136 newsize = max (Dynarr_min_size, multiplier * newsize); | 136 newsize = max (Dynarr_min_size, (int) (multiplier * newsize)); |
137 | 137 |
138 /* Don't do anything if the array is already big enough. */ | 138 /* Don't do anything if the array is already big enough. */ |
139 if (newsize > dy->max) | 139 if (newsize > dy->max) |
140 { | 140 { |
141 dy->base = xrealloc (dy->base, newsize*dy->elsize); | 141 dy->base = xrealloc (dy->base, newsize*dy->elsize); |
199 allocated beyond what was requested is returned in DYNARR_OVERHEAD | 199 allocated beyond what was requested is returned in DYNARR_OVERHEAD |
200 in STATS. The extra amount of space that malloc() allocates beyond | 200 in STATS. The extra amount of space that malloc() allocates beyond |
201 what was requested of it is returned in MALLOC_OVERHEAD in STATS. | 201 what was requested of it is returned in MALLOC_OVERHEAD in STATS. |
202 See the comment above the definition of this structure. */ | 202 See the comment above the definition of this structure. */ |
203 | 203 |
204 int | 204 size_t |
205 Dynarr_memory_usage (void *d, struct overhead_stats *stats) | 205 Dynarr_memory_usage (void *d, struct overhead_stats *stats) |
206 { | 206 { |
207 int total = 0; | 207 size_t total = 0; |
208 Dynarr *dy = (Dynarr *) d; | 208 Dynarr *dy = (Dynarr *) d; |
209 | 209 |
210 /* We have to be a bit tricky here because not all of the | 210 /* We have to be a bit tricky here because not all of the |
211 memory that malloc() will claim as "requested" was actually | 211 memory that malloc() will claim as "requested" was actually |
212 requested. */ | 212 requested. */ |
213 | 213 |
214 if (dy->base) | 214 if (dy->base) |
215 { | 215 { |
216 int malloc_used = malloced_storage_size (dy->base, | 216 size_t malloc_used = malloced_storage_size (dy->base, |
217 dy->elsize * dy->max, 0); | 217 dy->elsize * dy->max, 0); |
218 /* #### This may or may not be correct. Some Dynarrs would | 218 /* #### This may or may not be correct. Some Dynarrs would |
219 prefer that we use dy->cur instead of dy->largest here. */ | 219 prefer that we use dy->cur instead of dy->largest here. */ |
220 int was_requested = dy->elsize * dy->largest; | 220 int was_requested = dy->elsize * dy->largest; |
221 int dynarr_overhead = dy->elsize * (dy->max - dy->largest); | 221 int dynarr_overhead = dy->elsize * (dy->max - dy->largest); |
222 | 222 |