Closed
Bug 289606
Opened 20 years ago
Closed 20 years ago
two different definitions of EmptyString()
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
INVALID
People
(Reporter: dbaron, Unassigned)
Details
nsStringAPI.h and nsReadableUtils.h both define EmptyString() and EmptyCString(). In the latter, the string is a global static, but in the former, it's a temporary. Thus the code: const char *empty = EmptyString().get(); (see bug 236003 for an example) is valid with the latter (internal Mozilla code) but not the former. This is bad for people who might copy code. One of these versions should have a different name -- probably the nsStringAPI.h one, since it's easier to change and it doesn't look like it's been in a released version of nsStringAPI.h.
Comment 1•20 years ago
|
||
I don't get it. In both cases the value is a reference to the same static character buffer (nsCharTraits<CharT>::sEmptyBuffer).
| Reporter | ||
Comment 2•20 years ago
|
||
Oh, right. I was thinking that, in general, it's invalid to access a string's buffer after the string's destructor, but in this case it's ok, since we know it's the static empty buffer.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Updated•4 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•