Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3231)

Side by Side Diff: nss/mozilla/nsprpub/lib/ds/plarena.c

Issue 3135002: Update to NSS 3.12.7 and NSPR 4.8.6.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK ***** 2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * 4 *
5 * The contents of this file are subject to the Mozilla Public License Version 5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with 6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at 7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/ 8 * http://www.mozilla.org/MPL/
9 * 9 *
10 * Software distributed under the License is distributed on an "AS IS" basis, 10 * Software distributed under the License is distributed on an "AS IS" basis,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr) 249 PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr)
250 { 250 {
251 void *newp; 251 void *newp;
252 252
253 PL_ARENA_ALLOCATE(newp, pool, size + incr); 253 PL_ARENA_ALLOCATE(newp, pool, size + incr);
254 if (newp) 254 if (newp)
255 memcpy(newp, p, size); 255 memcpy(newp, p, size);
256 return newp; 256 return newp;
257 } 257 }
258 258
259 static void ClearArenaList(PLArena *a, PRInt32 pattern)
260 {
261
262 for (; a; a = a->next) {
263 PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
264 a->avail = a->base;
265 PL_CLEAR_UNUSED_PATTERN(a, pattern);
266 }
267 }
268
269 PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
270 {
271 ClearArenaList(pool->first.next, pattern);
272 }
273
259 /* 274 /*
260 * Free tail arenas linked after head, which may not be the true list head. 275 * Free tail arenas linked after head, which may not be the true list head.
261 * Reset pool->current to point to head in case it pointed at a tail arena. 276 * Reset pool->current to point to head in case it pointed at a tail arena.
262 */ 277 */
263 static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree) 278 static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
264 { 279 {
265 PLArena **ap, *a; 280 PLArena **ap, *a;
266 281
267 ap = &head->next; 282 ap = &head->next;
268 a = *ap; 283 a = *ap;
269 if (!a) 284 if (!a)
270 return; 285 return;
271 286
272 #ifdef DEBUG 287 #ifdef DEBUG
273 do { 288 ClearArenaList(a, PL_FREE_PATTERN);
274 PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
275 a->avail = a->base;
276 PL_CLEAR_UNUSED(a);
277 } while ((a = a->next) != 0);
278 a = *ap;
279 #endif 289 #endif
280 290
281 if (reallyFree) { 291 if (reallyFree) {
282 do { 292 do {
283 *ap = a->next; 293 *ap = a->next;
284 PL_CLEAR_ARENA(a); 294 PL_CLEAR_ARENA(a);
285 PL_COUNT_ARENA(pool,--); 295 PL_COUNT_ARENA(pool,--);
286 PR_DELETE(a); 296 PR_DELETE(a);
287 } while ((a = *ap) != 0); 297 } while ((a = *ap) != 0);
288 } else { 298 } else {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 fprintf(fp, " number of in-place growths: %u\n", stats->ninplace); 434 fprintf(fp, " number of in-place growths: %u\n", stats->ninplace);
425 fprintf(fp, "number of released allocations: %u\n", stats->nreleases); 435 fprintf(fp, "number of released allocations: %u\n", stats->nreleases);
426 fprintf(fp, " number of fast releases: %u\n", stats->nfastrels); 436 fprintf(fp, " number of fast releases: %u\n", stats->nfastrels);
427 fprintf(fp, " total bytes allocated: %u\n", stats->nbytes); 437 fprintf(fp, " total bytes allocated: %u\n", stats->nbytes);
428 fprintf(fp, " mean allocation size: %g\n", mean); 438 fprintf(fp, " mean allocation size: %g\n", mean);
429 fprintf(fp, " standard deviation: %g\n", sqrt(variance)); 439 fprintf(fp, " standard deviation: %g\n", sqrt(variance));
430 fprintf(fp, " maximum allocation size: %u\n", stats->maxalloc); 440 fprintf(fp, " maximum allocation size: %u\n", stats->maxalloc);
431 } 441 }
432 } 442 }
433 #endif /* PL_ARENAMETER */ 443 #endif /* PL_ARENAMETER */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698