Closed Bug 552548 Opened 15 years ago Closed 15 years ago

Use JSString accessors in ctypes instead of JS_GetStringChars

Categories

(Core :: js-ctypes, defect, P1)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: dwitte, Assigned: dwitte)

References

Details

Attachments

(1 file)

JS_GetStringChars can allocate, to guarantee a null-terminated buffer. That's bad; we don't need it, and it can fail. This requires moving ctypes into js/src.
P1, need this for 1.9.3. (Trivial to fix and it's a correctness bug.)
Priority: -- → P1
Attached patch like so (deleted) — Splinter Review
Assignee: nobody → dwitte
Status: NEW → ASSIGNED
Attachment #438005 - Flags: review?(bnewman)
Comment on attachment 438005 [details] [diff] [review] like so > static JS_ALWAYS_INLINE bool > IsEllipsis(jsval v) > { > if (!JSVAL_IS_STRING(v)) > return false; > JSString* str = JSVAL_TO_STRING(v); >- if (JS_GetStringLength(str) != 3) >- return false; >- jschar* chars = JS_GetStringChars(str), dot('.'); >+ if (str->length() != 3) >+ return false; >+ const jschar* chars = str->chars(), dot('.'); > return (chars[0] == dot && > chars[1] == dot && > chars[2] == dot); > } It's a shame how the `chars`s don't all line up vertically now.
Attachment #438005 - Flags: review?(bnewman) → review+
(In reply to comment #3) > It's a shame how the `chars`s don't all line up vertically now. Actually, it is kind of cool how the `char` part still aligns: const jschar return (char char char r=me, after all
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: