Closed
Bug 664353
Opened 13 years ago
Closed 13 years ago
Make alloc policy realloc() easier to implement
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: dvander, Assigned: dvander)
Details
Attachments
(1 file)
5.78 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
realloc() is annoying to implement in a bump allocator like IonAllocPolicy, so this changes jsvector to pass in the old size.
Attachment #539397 -
Flags: review?(luke)
Comment 1•13 years ago
|
||
Comment on attachment 539397 [details] [diff] [review] fix Review of attachment 539397 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/ion/IonAllocPolicy.h @@ +62,5 @@ > + void *realloc_(void *p, size_t oldBytes, size_t bytes) { > + void *n = malloc_(bytes); > + if (!n) > + return n; > + memcpy(n, p, oldBytes); In theory, bytes can be less than oldBytes in which case you need a Min() here. ::: js/src/jsvector.h @@ +157,5 @@ > > static inline bool growTo(Vector<T,N,AP> &v, size_t newcap) { > JS_ASSERT(!v.usingInlineStorage()); > size_t bytes = sizeof(T) * newcap; > + size_t oldBytes = sizeof(T) * v.mLength; Could you comment in jsalloc.h (first big comment) that realloc is passed the *used* bytes of the previous buffer, and not the total bytes allocated.
Attachment #539397 -
Flags: review?(luke) → review+
Assignee | ||
Comment 2•13 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/21e26c404883
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•