jasson库使用注意

  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()释放

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容