Closed Bug 5671 Opened 25 years ago Closed 25 years ago

nsXPIDL[C]String uses C++ allocator, not nsIAllocator, to alloc memory

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: waterson, Assigned: waterson)

References

Details

Need to fix it to use nsIAllocator, not new[] and delete[].
Status: NEW → ASSIGNED
Target Milestone: M6
*** Bug 5744 has been marked as a duplicate of this bug. ***
Target Milestone: M6 → M5
I have a fix ready to go in my tree. Moved to M5. jband: could you review for me? Index: nsXPIDLString.cpp =================================================================== RCS file: /cvsroot/mozilla/xpcom/src/nsXPIDLString.cpp,v retrieving revision 3.1 diff -c -r3.1 nsXPIDLString.cpp *** nsXPIDLString.cpp 1999/03/29 19:52:32 3.1 --- nsXPIDLString.cpp 1999/04/29 23:38:43 *************** *** 17,29 **** */ #include "nsDebug.h" #include "nsXPIDLString.h" #include "plstr.h" ! // XXX change to use nsIAllocator or whatever ! #define XPIDL_STRING_ALLOC(__size) new PRUnichar[(__size)] ! #define XPIDL_CSTRING_ALLOC(__size) new char[(__size)] ! #define XPIDL_FREE(__ptr) delete[] (__ptr) //////////////////////////////////////////////////////////////////////// // nsXPIDLString --- 17,30 ---- */ #include "nsDebug.h" + #include "nsIAllocator.h" #include "nsXPIDLString.h" #include "plstr.h" ! // If the allocator changes, fix it here. ! #define XPIDL_STRING_ALLOC(__len) ((PRUnichar*) nsAllocator::Alloc((__len) * sizeof(PRUnichar))) ! #define XPIDL_CSTRING_ALLOC(__len) ((char*) nsAllocator::Alloc((__len) * sizeof(char))) ! #define XPIDL_FREE(__ptr) (nsAllocator::Free(__ptr)) //////////////////////////////////////////////////////////////////////// // nsXPIDLString
Looks reasonable to me. It compiles and works, right? You don't need space for NULL string terminators? By the way, I don't much like the name. XPIDL is not really part of this. Isn't this really an nsXPCOMString ?
With respect to the length, caller is assumed to be adding one for the terminator. As for the name... :P
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Status: RESOLVED → VERIFIED
code fix, marking verified based on developer input
*** Bug 26350 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.