Changeset 58734 in vbox for trunk/src/libs/xpcom18a4/nsprpub
- Timestamp:
- Nov 18, 2015 10:24:35 AM (9 years ago)
- Location:
- trunk/src/libs/xpcom18a4/nsprpub/lib/ds
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarena.c
r1 r58734 116 116 pool->mask = PR_BITMASK(PR_CeilingLog2(align)); 117 117 pool->first.next = NULL; 118 /* Set all three addresses in pool->first to the same dummy value. 119 * These addresses are only compared with each other, but never 120 * dereferenced. */ 118 121 pool->first.base = pool->first.avail = pool->first.limit = 119 122 (PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1); … … 159 162 PLArena *a; 160 163 char *rp; /* returned pointer */ 164 PRUint32 nbOld; 161 165 162 166 PR_ASSERT((nb & pool->mask) == 0); 163 167 168 nbOld = nb; 164 169 nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */ 170 if (nb < nbOld) 171 return NULL; 165 172 166 173 /* attempt to allocate from arenas at pool->current */ … … 218 225 rp = (char *)a->avail; 219 226 a->avail += nb; 227 PR_ASSERT(a->avail <= a->limit); 220 228 /* the newly allocated arena is linked after pool->current 221 229 * and becomes pool->current */ … … 240 248 void *newp; 241 249 250 if (PR_UINT32_MAX - size < incr) 251 return NULL; 242 252 PL_ARENA_ALLOCATE(newp, pool, size + incr); 243 253 if (newp) -
trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarena.h
r1 r58734 109 109 PR_BEGIN_MACRO \ 110 110 PLArena *_a = (pool)->current; \ 111 PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \111 PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \ 112 112 PRUword _p = _a->avail; \ 113 PRUword _q = _p + _nb; \ 114 if (_q > _a->limit) \ 113 if (_nb < (PRUint32)nb) { \ 114 _p = 0; \ 115 } else if (_nb > (_a->limit - _a->avail)) { \ 115 116 _p = (PRUword)PL_ArenaAllocate(pool, _nb); \ 116 else \ 117 _a->avail = _q; \ 117 } else { \ 118 _a->avail += _nb; \ 119 } \ 118 120 p = (void *)_p; \ 119 PL_ArenaCountAllocation(pool, nb); \ 121 if (p) { \ 122 PL_ArenaCountAllocation(pool, nb); \ 123 } \ 120 124 PR_END_MACRO 121 125 … … 123 127 PR_BEGIN_MACRO \ 124 128 PLArena *_a = (pool)->current; \ 125 PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \126 PRUword _p = _a->avail;\127 PRUword _q = _p + _incr; \128 if (_p== (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \129 _ q <= _a->limit) { \130 _a->avail = _ q; \131 PL_ArenaCountInplaceGrowth(pool, size, incr); \129 PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \ 130 if (_incr < (PRUint32)incr) { \ 131 p = NULL; \ 132 } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \ 133 _incr <= (_a->limit - _a->avail)) { \ 134 _a->avail = _incr; \ 135 PL_ArenaCountInplaceGrowth(pool, size, (RTUint32)incr); \ 132 136 } else { \ 133 p = PL_ArenaGrow(pool, p, size, incr); \ 134 } \ 135 PL_ArenaCountGrowth(pool, size, incr); \ 137 p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \ 138 } \ 139 if (p) { \ 140 PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \ 141 } \ 136 142 PR_END_MACRO 137 143
Note:
See TracChangeset
for help on using the changeset viewer.