美文网首页
jasson库使用注意

jasson库使用注意

作者: 梦落迹南天 | 来源:发表于2019-04-16 16:37 被阅读0次
  1. json_decref()
    释放创建的object的引用,一些获取json_object返回的是new reference 需要手动进行释放:
json_t *json_object(void)¶
Return value: New reference.
Returns a new JSON object, or NULL on error. Initially, the object is empty.

但是有些函数返回的时候borrow reference :

json_t *json_object_get(const json_t *object, const char *key)¶
Return value: Borrowed reference.
Get a value corresponding to key from object. Returns NULL if key is not found and on error.

这是没有计入引用的使用,最好手动去json_incref(),然后手动json_decref()释放

相关文章

网友评论

      本文标题:jasson库使用注意

      本文链接:https://www.haomeiwen.com/subject/utgbwqtx.html