~ubuntu-branches/ubuntu/raring/gjs/raring

« back to all changes in this revision

Viewing changes to gjs/jsapi-util-array.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-03-13 19:15:08 UTC
  • mfrom: (1.6.7)
  • Revision ID: package-import@ubuntu.com-20120313191508-k44let6s97mb45uv
Tags: 1.31.20-0ubuntu1
* New upstream release.
* Add gir package
* debian/control.in: Require minimum glib 2.31
* Drop all patches since they've been applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
311
311
        gjs_rooted_array_append(context, array, value);
312
312
    }
313
313
 
314
 
#ifdef HAVE_JS_CLEARNEWBORNROOTS
315
314
    JS_ClearNewbornRoots(context);
316
 
#endif
317
315
    JS_GC(context);
318
316
 
319
317
    for (i = 0; i < N_ELEMS; i++) {
320
318
        char *ascii;
321
 
        JSString *str;
322
319
 
323
320
        value = gjs_rooted_array_get(context, array, i);
324
321
        g_assert(JSVAL_IS_STRING(value));
325
 
        str = JSVAL_TO_STRING(value);
326
 
#ifdef HAVE_JS_GETSTRINGBYTES
327
 
        ascii = g_strdup(JS_GetStringBytes(str));
328
 
#else
329
 
        size_t len = JS_GetStringEncodingLength(context, str);
330
 
        if (len == (size_t)(-1))
331
 
            continue;
332
 
 
333
 
        ascii = g_malloc((len + 1) * sizeof(char));
334
 
        JS_EncodeStringToBuffer(str, ascii, len);
335
 
        ascii[len] = '\0';
336
 
#endif
337
 
        /* if the string was freed, hopefully this will fail
338
 
         * even if we didn't crash yet
339
 
         */
 
322
        ascii = gjs_string_get_ascii(context, value);
340
323
        g_assert(strcmp(ascii, "abcdefghijk") == 0);
341
324
        g_free(ascii);
342
325
    }