* * NOTE nothing uses this and I'm not really maintaining it until * I know it's the desired API.
exn_newPrivate(JSContext *cx, JSErrorReport *report){    intN i;    JSExnPrivate *newPrivate;    JSErrorReport *newReport;    size_t capacity;    newPrivate = (JSExnPrivate *)JS_malloc(cx, sizeof (JSExnPrivate));    if (!newPrivate)        return NULL;    memset(newPrivate, 0, sizeof (JSExnPrivate));    /* Copy the error report */    newReport = (JSErrorReport *)JS_malloc(cx, sizeof (JSErrorReport));    if (!newReport)        goto error;    memset(newReport, 0, sizeof (JSErrorReport));    newPrivate->errorReport = newReport;    if (report->filename != NULL) {        newReport->filename = JS_strdup(cx, report->filename);        if (!newReport->filename)            goto error;    } else {        newReport->filename = NULL;    }    newReport->lineno = report->lineno;    /*     * We don't need to copy linebuf and tokenptr, because they     * point into the deflated string cache.  (currently?)     */    newReport->linebuf = report->linebuf;    newReport->tokenptr = report->tokenptr;    /*     * But we do need to copy uclinebuf, uctokenptr, because they're     * pointers into internal tokenstream structs, and may go away.     *     * NOTE nothing uses this and I'm not really maintaining it until     * I know it's the desired API.     */    if (report->uclinebuf != NULL) {	capacity = js_strlen(report->uclinebuf) + 1;        newReport->uclinebuf =            (const jschar *)JS_malloc(cx, capacity * sizeof(jschar));        if (!newReport->uclinebuf)            goto error;	js_strncpy((jschar *)newReport->uclinebuf, report->uclinebuf, capacity);	newReport->uctokenptr = newReport->uclinebuf + (report->uctokenptr -							report->uclinebuf);    } else {	newReport->uclinebuf = newReport->uctokenptr = NULL;    }    if (report->ucmessage != NULL) {        capacity = js_strlen(report->ucmessage) + 1;        newReport->ucmessage = (const jschar *)JS_malloc(cx, capacity * sizeof(jschar));        if (!newReport->ucmessage)            goto error;        js_strncpy((jschar *)newReport->ucmessage, report->ucmessage, capacity);        if (report->messageArgs) {            for (i = 0; report->messageArgs[i] != NULL; i++)                ;            JS_ASSERT(i);            newReport->messageArgs =                (const jschar **)JS_malloc(cx, (i + 1) * sizeof(jschar *));            if (!newReport->messageArgs)                goto error;            for (i = 0; report->messageArgs[i] != NULL; i++) {                capacity = js_strlen(report->messageArgs[i]) + 1;                newReport->messageArgs[i] =                    (const jschar *)JS_malloc(cx, capacity * sizeof(jschar));                if (!newReport->messageArgs[i])                    goto error;                js_strncpy((jschar *)(newReport->messageArgs[i]),                           report->messageArgs[i], capacity);            }            newReport->messageArgs[i] = NULL;        } else {            newReport->messageArgs = NULL;        }    } else {        newReport->ucmessage = NULL;        newReport->messageArgs = NULL;    }    newReport->errorNumber = report->errorNumber;    /* Note that this is before it gets flagged with JSREPORT_EXCEPTION */    newReport->flags = report->flags;    return newPrivate;error:    exn_destroyPrivate(cx, newPrivate);    return NULL;}