Skip to content
Snippets Groups Projects
Commit 471cea1f authored by deuce's avatar deuce
Browse files

Add *_TO_MSTRING() macros to return malloc()ed strings instead of the current

alloca()ed ones.
parent f3b8a39b
No related branches found
No related tags found
No related merge requests found
......@@ -111,6 +111,33 @@ extern int thread_suid_broken; /* NPTL is no longer broken */
#include <jsapi.h>
#define JS_DestroyScript(cx,script)
#define JSSTRING_TO_MSTRING(cx, str, ret, lenptr) \
{ \
size_t *JSSTSlenptr=lenptr; \
size_t JSSTSlen; \
size_t JSSTSpos; \
const jschar *JSSTSstrval; \
\
if(JSSTSlenptr==NULL) \
JSSTSlenptr=&JSSTSlen; \
(ret)=NULL; \
if((str) != NULL) { \
if((JSSTSstrval=JS_GetStringCharsAndLength((cx), (str), JSSTSlenptr))) { \
if(((ret)=(char *)malloc(*JSSTSlenptr+1))) { \
for(JSSTSpos=0; JSSTSpos<*JSSTSlenptr; JSSTSpos++) \
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
} \
} \
}
#define JSVALUE_TO_MSTRING(cx, val, ret, lenptr) \
{ \
JSString *JSVTSstr=JS_ValueToString((cx), (val)); \
JSSTRING_TO_MSTRING((cx), JSVTSstr, (ret), lenptr); \
}
#define JSSTRING_TO_STRING(cx, str, ret, lenptr) \
{ \
size_t *JSSTSlenptr=lenptr; \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment