gpt4 book ai didi

c - 如何释放 json_object?

转载 作者:太空狗 更新时间:2023-10-29 16:56:16 25 4
gpt4 key购买 nike

我有以下代码

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>

#include <json/json.h>

int main(int argc, char **argv)
{
json_object *new_obj;
char buf[] = "{ \"foo\": \"bar\", \"foo2\": \"bar2\", \"foo3\": \"bar3\" }";
new_obj = json_tokener_parse(buf);
.....
json_object_put(new_obj);
}

json_object_put(new_obj) 是否释放与 new_obj 相关的所有内存?

最佳答案

来自文档:

void json_object_put    (struct json_object *this)  

Decrement the reference count of json_object and free if it reaches zero

来源: http://oss.metaparadigm.com/json-c/doc/html/json__object_8h.html

关于c - 如何释放 json_object?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14879994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com