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)
Core
XPCOM
Tracking
()
VERIFIED
FIXED
M5
People
(Reporter: waterson, Assigned: waterson)
References
Details
Need to fix it to use nsIAllocator, not new[] and delete[].
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Target Milestone: M6
Assignee | ||
Updated•25 years ago
|
Target Milestone: M6 → M5
Assignee | ||
Comment 2•25 years ago
|
||
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
Comment 3•25 years ago
|
||
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 ?
Assignee | ||
Comment 4•25 years ago
|
||
With respect to the length, caller is assumed to be adding one for the
terminator.
As for the name... :P
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Updated•25 years ago
|
Status: RESOLVED → VERIFIED
Comment 5•25 years ago
|
||
code fix, marking verified based on developer input
You need to log in
before you can comment on or make changes to this bug.
Description
•