• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ JS_malloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中JS_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_malloc函数的具体用法?C++ JS_malloc怎么用?C++ JS_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了JS_malloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: js_InitNavigatorClass

JSObject *
js_InitNavigatorClass(JSContext *cx, JSObject *obj) {
	
	JSObject *Navigator;

	Navigator = JS_DefineObject(cx, obj, "navigator", &navigator_class, NULL, 0);
  if (!Navigator)
  	return NULL;
  if (!JS_DefineFunctions(cx, Navigator, navigator_static_methods))
  	return NULL;
  if (!JS_DefineProperties(cx, Navigator, navigator_properties))
  	return NULL;

    CMNavigator *cmNav;

   cmNav = JS_malloc(cx, sizeof *cmNav);
  if (!cmNav)
     return NULL;
  memset(cmNav, 0 , sizeof *cmNav);

  cmNav->appVersion = JS_malloc(cx, strlen("Firefox/2"));
  cmNav->appVersion = strdup("Firefox/2");

JS_SetPrivate(cx, Navigator, cmNav);

  return Navigator;
}
开发者ID:pankajtanwar,项目名称:ponkey,代码行数:27,代码来源:jsnavigator.c


示例2: JS_SetTrap

JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
           JSTrapHandler handler, void *closure)
{
    JSRuntime *rt;
    JSTrap *trap;

    rt = cx->runtime;
    trap = FindTrap(rt, script, pc);
    if (trap) {
        /* Restore opcode at pc so it can be saved again. */
        *pc = (jsbytecode)trap->op;
    } else {
        trap = (JSTrap *) JS_malloc(cx, sizeof *trap);
        if (!trap || !js_AddRoot(cx, &trap->closure, "trap->closure")) {
            if (trap)
                JS_free(cx, trap);
            return JS_FALSE;
        }
    }
    JS_APPEND_LINK(&trap->links, &rt->trapList);
    trap->script = script;
    trap->pc = pc;
    trap->op = (JSOp)*pc;
    trap->handler = handler;
    trap->closure = closure;
    *pc = JSOP_TRAP;
    return JS_TRUE;
}
开发者ID:DmitrySigaev,项目名称:DSMedia,代码行数:28,代码来源:jsdbgapi.c


示例3: wimg_image_info_setter

JSBool wimg_image_info_setter(JSContext * cx, JSObject * obj, jsval idval, jsval * vp)
{
    JS_BeginRequest(cx);
    HANDLE hImage = JS_GetPrivate(cx, obj);

    JSString * newInfo = JS_ValueToString(cx, *vp);
    *vp = STRING_TO_JSVAL(newInfo);

    DWORD length = JS_GetStringLength(newInfo);
    LPWSTR chars = (LPWSTR)JS_GetStringChars(newInfo);
    if(*chars != 0xfeff)
    {
        length++;
        LPWSTR back = chars;
        chars = (LPWSTR)JS_malloc(cx, sizeof(WCHAR) * (length + 1));
        memset(chars, 0, sizeof(WCHAR) * (length + 1));
        *chars = 0xfeff;
        wcscat(chars, back);
        newInfo = JS_NewUCString(cx, (jschar*)chars, sizeof(WCHAR) * length);
        *vp = STRING_TO_JSVAL(newInfo);
    }

    DWORD errorCode = 0;
    if(!WIMSetImageInformation(hImage, (LPVOID)chars, length * sizeof(WCHAR)))
        errorCode = GetLastError();
    JS_EndRequest(cx);
    return JS_TRUE;

}
开发者ID:z4y4,项目名称:njord,代码行数:29,代码来源:js_wimg.cpp


示例4: sizeof

// static
JSString*
DOMProxyHandler::obj_toString(JSContext* cx, const char* className)
{
  size_t nchars = sizeof("[object ]") - 1 + strlen(className);
  jschar* chars = static_cast<jschar*>(JS_malloc(cx, (nchars + 1) * sizeof(jschar)));
  if (!chars) {
    return NULL;
  }

  const char* prefix = "[object ";
  nchars = 0;
  while ((chars[nchars] = (jschar)*prefix) != 0) {
    nchars++, prefix++;
  }
  while ((chars[nchars] = (jschar)*className) != 0) {
    nchars++, className++;
  }
  chars[nchars++] = ']';
  chars[nchars] = 0;

  JSString* str = JS_NewUCString(cx, chars, nchars);
  if (!str) {
    JS_free(cx, chars);
  }
  return str;
}
开发者ID:petemoore,项目名称:mozilla-central,代码行数:27,代码来源:DOMJSProxyHandler.cpp


示例5: JS_SetTrap

JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
           JSTrapHandler handler, void *closure)
{
    JSRuntime *rt;
    JSTrap *trap;

    rt = cx->runtime;
    trap = FindTrap(rt, script, pc);
    if (trap) {
        JS_ASSERT(trap->script == script && trap->pc == pc);
        JS_ASSERT(*pc == JSOP_TRAP);
    } else {
        trap = (JSTrap *) JS_malloc(cx, sizeof *trap);
        if (!trap || !js_AddRoot(cx, &trap->closure, "trap->closure")) {
            if (trap)
                JS_free(cx, trap);
            return JS_FALSE;
        }
        JS_APPEND_LINK(&trap->links, &rt->trapList);
        trap->script = script;
        trap->pc = pc;
        trap->op = (JSOp)*pc;
        *pc = JSOP_TRAP;
    }
    trap->handler = handler;
    trap->closure = closure;
    return JS_TRUE;
}
开发者ID:bluecherrydvr,项目名称:omv,代码行数:28,代码来源:jsdbgapi.c


示例6: gpsee_throw

/** Throw an exception from our C code to be caught by the 
 *  running JavaScript program.
 *
 *  To use this function, in most cases, do:
 *  <pre>
 *  if (badness)
 *    return gpsee_throw(cx, "bad things just happened");
 *  </pre>
 *
 *  @param	cx	Context from which to device runtime information
 *  @param	fmt	printf-style format for the text to throw as an exception
 *  @param	...	printf-style arguments to fmt
 *
 *  @returns	JS_FALSE
 *
 *  @warning	This function will panic if the runtime cannot allocate 
 *		enough memory to prepare the exception-throwing message.
 *
 *  @note	This function uses the APR SureLynx gpsee_makeLogFormat() function,
 *		so %m will work, and so will addPercentM_Handler() with surelynx.
 */
JSBool gpsee_throw(JSContext *cx, const char *fmt, ...)
{
  char 		*message;
  va_list	ap;
  size_t	length;
  char		fmtNew[GPSEE_MAX_LOG_MESSAGE_SIZE];

  message = JS_malloc(cx, GPSEE_MAX_THROW_MESSAGE_SIZE);
  if (!message)
    panic(GPSEE_GLOBAL_NAMESPACE_NAME ": out of memory in gpsee_throw!");

  va_start(ap, fmt);
  length = vsnprintf(message, GPSEE_MAX_THROW_MESSAGE_SIZE, gpsee_makeLogFormat(fmt, fmtNew), ap);
  va_end(ap);

  if (length <= 0)
  {
    gpsee_cpystrn(message, "JS Engine unnamed exception", GPSEE_MAX_THROW_MESSAGE_SIZE);
    length = strlen(message);
  }

  if (JS_IsExceptionPending(cx) == JS_TRUE)
    gpsee_log(cx, GLOG_ERR, GPSEE_GLOBAL_NAMESPACE_NAME ": Already throwing an exception; not throwing '%s'!", message);
  else
    JS_ReportError(cx, "%s", message);

  return JS_FALSE;
}
开发者ID:wesgarland,项目名称:gpsee,代码行数:49,代码来源:gpsee.c


示例7: win32_getenv

JSBool win32_getenv(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
	JS_BeginRequest(cx);
	if(argc < 1)
	{
		JS_ReportError(cx, "getenv requires the name of the variable to be passed");
		JS_EndRequest(cx);
		return JS_FALSE;
	}
	JSString * name = JS_ValueToString(cx, argv[0]);
	DWORD size = GetEnvironmentVariable((LPWSTR)JS_GetStringChars(name), NULL, 0);
	if(size == 0)
	{
		*rval = JSVAL_FALSE;
		JS_EndRequest(cx);
		return JS_TRUE;
	}
	LPWSTR valueBuffer = (LPWSTR)JS_malloc(cx, (size + 2) * sizeof(WCHAR));
	size = GetEnvironmentVariable((LPWSTR)JS_GetStringChars(name), valueBuffer, size + 1);
	if(size == 0)
	{
		JS_free(cx, valueBuffer);
		*rval = JSVAL_FALSE;
		JS_EndRequest(cx);
		return JS_TRUE;
	}
	JSString * value = JS_NewUCString(cx, valueBuffer, size + 1);
	*rval = STRING_TO_JSVAL(value);
	JS_EndRequest(cx);
	return JS_TRUE;
}
开发者ID:z4y4,项目名称:njord,代码行数:31,代码来源:win32s.cpp


示例8: JSGET_PTRSHELL

JSBool S_CCMenuItemLabel::jsitemWithLabel(JSContext *cx, uint32_t argc, jsval *vp) {
    JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
    S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj);
    if (self == NULL) return JS_FALSE;
    if (argc == 1) {
        JSObject *arg0;
        JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0);
        CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
        CCMenuItemLabel *ret = CCMenuItemLabel::itemWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction));
        if (ret == NULL) {
            JS_SET_RVAL(cx, vp, JSVAL_NULL);
            return JS_TRUE;
        }
        do {
            JSObject *tmp = JS_NewObject(cx, S_CCMenuItemLabel::jsClass, S_CCMenuItemLabel::jsObject, NULL);
            pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
            pt->flags = kPointerTemporary;
            pt->data = (void *)ret;
            JS_SetPrivate(tmp, pt);
            JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
        } while(0);
        
        return JS_TRUE;
    }
    JS_SET_RVAL(cx, vp, JSVAL_TRUE);
    return JS_TRUE;
}
开发者ID:136446529,项目名称:book-code,代码行数:27,代码来源:cocos2d_manual_bindings.cpp


示例9: jsRead

static JSBool
jsRead( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval )
{
    *rval = JSVAL_FALSE ;
    jsUsblpPoll_t *dev = (jsUsblpPoll_t *)JS_GetInstancePrivate( cx, obj, &jsUsblpClass_, NULL );
    if( dev )
    {
        unsigned numAvail = dev->bytesAvail();
        if( 0 < numAvail ) {
            char *const inBuf = (char *)JS_malloc( cx, numAvail+1 );
            unsigned numRead ;
            if( dev->read( inBuf, numAvail, numRead ) ) {
                JSString *sData = JS_NewString( cx, inBuf, numRead );
                *rval = STRING_TO_JSVAL( sData );
            }
            else {
                JS_ReportError( cx, "usblp read error\n" );
                JS_free(cx, inBuf);
            }
        }
    }
    else
        JS_ReportError( cx, "Invalid usblp object\n" );
    return JS_TRUE ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:25,代码来源:jsUsblp.cpp


示例10: JS_ConvertArguments

JSBool S_CCLabelTTF::jslabelWithString(JSContext *cx, uint32_t argc, jsval *vp) {
    if (argc == 5) {
        JSString *arg0;
        JSObject *arg1;
        int arg2;
        JSString *arg3;
        double arg4;
        JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4);
        char *narg0 = JS_EncodeString(cx, arg0);
        CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1);
        char *narg3 = JS_EncodeString(cx, arg3);
        CCLabelTTF *ret = CCLabelTTF::labelWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4);
        if (ret == NULL) {
            JS_SET_RVAL(cx, vp, JSVAL_NULL);
            return JS_TRUE;
        }
        do {
            JSObject *tmp = JS_NewObject(cx, S_CCLabelTTF::jsClass, S_CCLabelTTF::jsObject, NULL);
            pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
            pt->flags = kPointerTemporary;
            pt->data = (void *)ret;
            JS_SetPrivate(tmp, pt);
            JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
        } while (0);
        return JS_TRUE;
    }
    JS_SET_RVAL(cx, vp, JSVAL_TRUE);
    return JS_TRUE;
}
开发者ID:136446529,项目名称:book-code,代码行数:29,代码来源:cocos2d_manual_bindings.cpp


示例11: JS_XDRString

JS_XDRString(JSXDRState *xdr, JSString **strp)
{
    uint32 nchars;
    jschar *chars;

    if (xdr->mode == JSXDR_ENCODE)
        nchars = JSSTRING_LENGTH(*strp);
    if (!JS_XDRUint32(xdr, &nchars))
        return JS_FALSE;

    if (xdr->mode == JSXDR_DECODE) {
        chars = (jschar *) JS_malloc(xdr->cx, (nchars + 1) * sizeof(jschar));
        if (!chars)
            return JS_FALSE;
    } else {
        chars = JSSTRING_CHARS(*strp);
    }

    if (!XDRChars(xdr, chars, nchars))
        goto bad;
    if (xdr->mode == JSXDR_DECODE) {
        chars[nchars] = 0;
        *strp = JS_NewUCString(xdr->cx, chars, nchars);
        if (!*strp)
            goto bad;
    }
    return JS_TRUE;

bad:
    if (xdr->mode == JSXDR_DECODE)
        JS_free(xdr->cx, chars);
    return JS_FALSE;
}
开发者ID:2812140729,项目名称:robomongo,代码行数:33,代码来源:jsxdrapi.c


示例12: recv_body

static size_t
recv_body(void *ptr, size_t size, size_t nmem, void *data)
{
    CurlState* state = (CurlState*) data;
    size_t length = size * nmem;
    char* tmp = NULL;
    
    if(!state->recvbuf) {
        state->recvlen = 4096;
        state->read = 0;
        state->recvbuf = JS_malloc(state->cx, state->recvlen);
    }
    
    if(!state->recvbuf) {
        return CURLE_WRITE_ERROR;
    }

    // +1 so we can add '\0' back up in the go function.
    while(length+1 > state->recvlen - state->read) state->recvlen *= 2;
    tmp = JS_realloc(state->cx, state->recvbuf, state->recvlen);
    if(!tmp) return CURLE_WRITE_ERROR;
    state->recvbuf = tmp;
   
    memcpy(state->recvbuf + state->read, ptr, length);
    state->read += length;
    return length;
}
开发者ID:AvianFlu,项目名称:couchdb,代码行数:27,代码来源:http.c


示例13: __Window_readLine

JSString*
__Window_readLine (JSContext* cx, WINDOW* win, JSBool moveFirst, jsval x, jsval y)
{
    char* string  = (char*) JS_malloc(cx, 16*sizeof(char));
    size_t length = 0;

    JS_BeginRequest(cx);
    JS_EnterLocalRootScope(cx);

    string[0] = (moveFirst
        ? mvwgetch(win, JSVAL_TO_INT(y), JSVAL_TO_INT(x))
        : wgetch(win));
    
    while (string[(++length)-1] != '\n') {
        if ((length+1) % 16) {
            string = (char*) JS_realloc(cx, string, (length+16+1)*sizeof(char));
        }
    
        string[length] = (char) wgetch(win);
    }

    string[length-1] = '\0';
    string = (char*) JS_realloc(cx, string, length*sizeof(char));

    JSString* jsString = JS_NewString(cx, string, strlen(string));

    JS_LeaveLocalRootScope(cx);
    JS_EndRequest(cx);
    return jsString;
}
开发者ID:meh,项目名称:lulzjs-ncurses,代码行数:30,代码来源:Window.cpp


示例14: JS_ARGV

JSBool S_CCSequence::jsactions(JSContext *cx, uint32_t argc, jsval *vp) {
    // just like CCSequence::actions
    if (argc > 0) {
        jsval* argv = JS_ARGV(cx, vp);
        // get first element
        S_CCSequence* prev;
        JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0]));
        for (int i=1; i < argc; i++) {
            CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i]));
            prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next);
        }
        // wrap prev in an action
        // temporary because it's just a wrapper for an autoreleased object
        // or worst case, it's an already binded object (if it's just one item in the array)
        pointerShell_t* pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
        pt->flags = kPointerTemporary;
        pt->data = prev;
        JSObject* out = JS_NewObject(cx, S_CCSequence::jsClass, S_CCSequence::jsObject, NULL);
        prev->jsObject = out;
        JS_SetPrivate(out, pt);
        JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(out));
        return JS_TRUE;
    }
    JS_ReportError(cx, "must call with at least one element");
    return JS_FALSE;
}
开发者ID:136446529,项目名称:book-code,代码行数:26,代码来源:cocos2d_manual_bindings.cpp


示例15: enc_string

char*
enc_string(JSContext* cx, jsval arg, size_t* buflen)
{
    JSString* str = NULL;
    jschar* src = NULL;
    char* bytes = NULL;
    size_t srclen = 0;
    size_t byteslen = 0;

    str = JS_ValueToString(cx, arg);
    if(!str) goto error;

    src = JS_GetStringChars(str);
    srclen = JS_GetStringLength(str);

    if(!enc_charbuf(src, srclen, NULL, &byteslen)) goto error;

    bytes = JS_malloc(cx, (byteslen) + 1);
    bytes[byteslen] = 0;

    if(!enc_charbuf(src, srclen, bytes, &byteslen)) goto error;

    if(buflen) *buflen = byteslen;
    goto success;

error:
    if(bytes != NULL) JS_free(cx, bytes);
    bytes = NULL;

success:
    return bytes;
}
开发者ID:benoitc,项目名称:couchjs,代码行数:32,代码来源:utf8.c


示例16: js_PushLocalRoot

int
js_PushLocalRoot(JSContext *cx, JSLocalRootStack *lrs, jsval v)
{
    unsigned n, m;
    JSLocalRootChunk *lrc;

    n = lrs->rootCount;
    m = n & JSLRS_CHUNK_MASK;
    if (n == 0 || m != 0) {
        /*
         * At start of first chunk, or not at start of a non-first top chunk.
         * Check for lrs->rootCount overflow.
         */
        if ((uint16)(n + 1) == 0) {
            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                                 JSMSG_TOO_MANY_LOCAL_ROOTS);
            return -1;
        }
        lrc = lrs->topChunk;
        JS_ASSERT(n != 0 || lrc == &lrs->firstChunk);
    } else {
        /*
         * After lrs->firstChunk, trying to index at a power-of-two chunk
         * boundary: need a new chunk.
         */
        lrc = (JSLocalRootChunk *) JS_malloc(cx, sizeof *lrc);
        if (!lrc)
            return -1;
        lrc->down = lrs->topChunk;
        lrs->topChunk = lrc;
    }
    lrs->rootCount = n + 1;
    lrc->roots[m] = v;
    return (int) m;
}
开发者ID:bluecherrydvr,项目名称:omv,代码行数:35,代码来源:jscntxt.c


示例17: define_JavaPackage

static JSObject *
define_JavaPackage(JSContext *cx, JSObject *parent_obj,
                   const char *obj_name, const char *path, int flags, int access)
{
    JSObject *package_obj;
    JavaPackage_Private *package;

    package_obj = JS_DefineObject(cx, parent_obj, obj_name, &JavaPackage_class, 0, JSPROP_PERMANENT | access);
    
    if (!package_obj)
        return NULL;
    
    /* Attach private, native data to the JS object */
    package = (JavaPackage_Private *)JS_malloc(cx, sizeof(JavaPackage_Private));
    JS_SetPrivate(cx, package_obj, (void *)package);
    if (path)
        package->path = JS_strdup(cx, path);
    else
        package->path = "";

    package->flags = flags;

    /* Check for OOM */
    if (!package->path) {
        JS_DeleteProperty(cx, parent_obj, obj_name);
        JS_free(cx, package);
        return NULL;
    }

    return package_obj;
}
开发者ID:Kitiara,项目名称:UOX3,代码行数:31,代码来源:jsj_JavaPackage.c


示例18: js_EnterLocalRootScope

JSBool
js_EnterLocalRootScope(JSContext *cx)
{
    JSLocalRootStack *lrs;
    int mark;

    lrs = cx->localRootStack;
    if (!lrs) {
        lrs = (JSLocalRootStack *) JS_malloc(cx, sizeof *lrs);
        if (!lrs)
            return JS_FALSE;
        lrs->scopeMark = JSLRS_NULL_MARK;
        lrs->rootCount = 0;
        lrs->topChunk = &lrs->firstChunk;
        lrs->firstChunk.down = NULL;
        cx->localRootStack = lrs;
    }

    /* Push lrs->scopeMark to save it for restore when leaving. */
    mark = js_PushLocalRoot(cx, lrs, INT_TO_JSVAL(lrs->scopeMark));
    if (mark < 0)
        return JS_FALSE;
    lrs->scopeMark = (uint16) mark;
    return JS_TRUE;
}
开发者ID:bluecherrydvr,项目名称:omv,代码行数:25,代码来源:jscntxt.c


示例19: ejszlib_compress

  static
  JSBool
  ejszlib_compress (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) 
  {
    EJS_CHECK_NUM_ARGS(cx,obj,1,argc);
    
    char* ctype;
    size_t len;
    STRING_TO_CHARVEC(argv[0],ctype,len);
    // todo: perhaps simply return an empty string
    if (!len) EJS_THROW_ERROR(cx,obj,"nothing to compress");
    
    uLong destLen=compressBound(len);
    
    Byte* dest=(Byte *)JS_malloc(cx, destLen);
    if (!dest) return JS_FALSE;

    if (compress(dest, &destLen, (Byte*)ctype, len)!=Z_OK) {
      JS_free(cx,dest);
      EJS_THROW_ERROR(cx,obj,"compression failed");
    }

    assert(destLen>0);
    dest=(Byte *)JS_realloc(cx,dest,destLen);

    RETSTR(dest,destLen,rval);
  }
开发者ID:BackupTheBerlios,项目名称:egachine,代码行数:27,代码来源:ejszlib.cpp


示例20: jsj_GetJavaMemberDescriptor

JavaMemberDescriptor *
jsj_GetJavaMemberDescriptor(JSContext *cx,
                            JNIEnv *jEnv, 
                            JavaClassDescriptor *class_descriptor,
                            jstring member_name_jstr)
{
    JavaMemberDescriptor *member_descriptor;
    jsid id;

    if (!JavaStringToId(cx, jEnv, member_name_jstr, &id))
        return NULL;

    member_descriptor = jsj_LookupJavaMemberDescriptorById(cx, jEnv, class_descriptor, id);
    if (member_descriptor)
        return member_descriptor;

    member_descriptor = JS_malloc(cx, sizeof(JavaMemberDescriptor));
    if (!member_descriptor)
        return NULL;
    memset(member_descriptor, 0, sizeof(JavaMemberDescriptor));

    member_descriptor->name = jsj_DupJavaStringUTF(cx, jEnv, member_name_jstr);
    if (!member_descriptor->name) {
        JS_free(cx, member_descriptor);
        return NULL;
    }
    member_descriptor->id = id;

    member_descriptor->next = class_descriptor->instance_members;
    class_descriptor->instance_members = member_descriptor;

    return member_descriptor;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:33,代码来源:jsj_class.c



注:本文中的JS_malloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JString函数代码示例发布时间:2022-05-30
下一篇:
C++ JS_ValueToString函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap