Opened 20 years ago
Closed 20 years ago
#803 closed defect (fixed)
psRealloc simply calls realloc without reference to the psAlloc mem manager
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | sys | Version: | unspecified |
| Severity: | normal | Keywords: | |
| Cc: |
Description
psRealloc calls realloc on a block that belongs to the psLib memory allocator; unfortunately,
that allocator assumes that blocks have sizes that are powers of two (up to 216; but see bug 804)
and this is violated by a call to realloc().
A simple fix is to call psAlloc to get the expanded memory block (if needed); I have implemented
this and will check it in after suitable consultation
Change History (3)
comment:1 by , 20 years ago
| Cc: | added |
|---|---|
| Owner: | changed from to |
comment:2 by , 20 years ago
comment:3 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Rolled back the psAlloc + copy solution (see bug 801) and instead added to the
top of p_psRealloc:
Ensure the size matches that of the recycle bin
int bin = getRecycleBin(size);
if (bin < N_RECYCLE_BINS) {
size = recycleBinSize[bin]; round-up size to next sized bin.
}
This ensures that the size returned from realloc() is a power of two.
Note that you now need to define PS_MEM_USE_RECYCLE at compile time to use
recycling bins.

* Bug 801 has been marked as a duplicate of this bug. *