mirror of
https://github.com/json-c/json-c.git
synced 2026-04-08 23:09:07 +08:00
rollback api to 0.12
This commit is contained in:
@@ -64,7 +64,7 @@ array_list_free(struct array_list *arr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
array_list_get(struct array_list *arr, size_t i)
|
array_list_get_idx(struct array_list *arr, size_t i)
|
||||||
{
|
{
|
||||||
if(i >= arr->length) return NULL;
|
if(i >= arr->length) return NULL;
|
||||||
return arr->array[i];
|
return arr->array[i];
|
||||||
@@ -94,7 +94,7 @@ static int array_list_expand_internal(struct array_list *arr, size_t max)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
array_list_insert(struct array_list *arr, size_t idx, void *data)
|
array_list_put_idx(struct array_list *arr, size_t idx, void *data)
|
||||||
{
|
{
|
||||||
if (idx > SIZE_T_MAX - 1 ) return -1;
|
if (idx > SIZE_T_MAX - 1 ) return -1;
|
||||||
if(array_list_expand_internal(arr, idx+1)) return -1;
|
if(array_list_expand_internal(arr, idx+1)) return -1;
|
||||||
@@ -108,7 +108,7 @@ array_list_insert(struct array_list *arr, size_t idx, void *data)
|
|||||||
int
|
int
|
||||||
array_list_add(struct array_list *arr, void *data)
|
array_list_add(struct array_list *arr, void *data)
|
||||||
{
|
{
|
||||||
return array_list_insert(arr, arr->length, data);
|
return array_list_put_idx(arr, arr->length, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ extern void
|
|||||||
array_list_free(struct array_list *al);
|
array_list_free(struct array_list *al);
|
||||||
|
|
||||||
extern void*
|
extern void*
|
||||||
array_list_get(struct array_list *al, size_t i);
|
array_list_get_idx(struct array_list *al, size_t i);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
array_list_insert(struct array_list *al, size_t i, void *data);
|
array_list_put_idx(struct array_list *al, size_t i, void *data);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
array_list_add(struct array_list *al, void *data);
|
array_list_add(struct array_list *al, void *data);
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, int len, int fl
|
|||||||
|
|
||||||
/* reference counting */
|
/* reference counting */
|
||||||
|
|
||||||
extern struct json_object* json_object_retain(struct json_object *jso)
|
extern struct json_object* json_object_get(struct json_object *jso)
|
||||||
{
|
{
|
||||||
if (!jso) return jso;
|
if (!jso) return jso;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ extern struct json_object* json_object_retain(struct json_object *jso)
|
|||||||
return jso;
|
return jso;
|
||||||
}
|
}
|
||||||
|
|
||||||
int json_object_release(struct json_object *jso)
|
int json_object_put(struct json_object *jso)
|
||||||
{
|
{
|
||||||
if(!jso) return 0;
|
if(!jso) return 0;
|
||||||
|
|
||||||
@@ -414,7 +414,7 @@ static void json_object_lh_entry_free(struct lh_entry *ent)
|
|||||||
{
|
{
|
||||||
if (!ent->k_is_constant)
|
if (!ent->k_is_constant)
|
||||||
free(lh_entry_k(ent));
|
free(lh_entry_k(ent));
|
||||||
json_object_release((struct json_object*)lh_entry_v(ent));
|
json_object_put((struct json_object*)lh_entry_v(ent));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void json_object_object_delete(struct json_object* jso)
|
static void json_object_object_delete(struct json_object* jso)
|
||||||
@@ -487,7 +487,7 @@ int json_object_object_add_ex(struct json_object* jso,
|
|||||||
}
|
}
|
||||||
existing_value = (json_object *) lh_entry_v(existing_entry);
|
existing_value = (json_object *) lh_entry_v(existing_entry);
|
||||||
if (existing_value)
|
if (existing_value)
|
||||||
json_object_release(existing_value);
|
json_object_put(existing_value);
|
||||||
existing_entry->v = val;
|
existing_entry->v = val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1102,7 +1102,7 @@ static int json_object_array_to_json_string(struct json_object* jso,
|
|||||||
|
|
||||||
static void json_object_array_entry_free(void *data)
|
static void json_object_array_entry_free(void *data)
|
||||||
{
|
{
|
||||||
json_object_release((struct json_object*)data);
|
json_object_put((struct json_object*)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void json_object_array_delete(struct json_object* jso)
|
static void json_object_array_delete(struct json_object* jso)
|
||||||
@@ -1179,7 +1179,7 @@ int json_object_array_put_idx(struct json_object *jso, size_t idx,
|
|||||||
struct json_object *val)
|
struct json_object *val)
|
||||||
{
|
{
|
||||||
assert(json_object_get_type(jso) == json_type_array);
|
assert(json_object_get_type(jso) == json_type_array);
|
||||||
return array_list_insert(jso->o.c_array, idx, val);
|
return array_list_put_idx(jso->o.c_array, idx, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int json_object_array_del_idx(struct json_object *jso, size_t idx, size_t count)
|
int json_object_array_del_idx(struct json_object *jso, size_t idx, size_t count)
|
||||||
@@ -1192,7 +1192,7 @@ struct json_object* json_object_array_get_idx(const struct json_object *jso,
|
|||||||
size_t idx)
|
size_t idx)
|
||||||
{
|
{
|
||||||
assert(json_object_get_type(jso) == json_type_array);
|
assert(json_object_get_type(jso) == json_type_array);
|
||||||
return (struct json_object*)array_list_get(jso->o.c_array, idx);
|
return (struct json_object*)array_list_get_idx(jso->o.c_array, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_array_equal(struct json_object* jso1,
|
static int json_array_equal(struct json_object* jso1,
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ typedef enum json_type {
|
|||||||
*
|
*
|
||||||
* @param obj the json_object instance
|
* @param obj the json_object instance
|
||||||
*/
|
*/
|
||||||
JSON_EXPORT struct json_object* json_object_retain(struct json_object *obj);
|
JSON_EXPORT struct json_object* json_object_get(struct json_object *obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrement the reference count of json_object and free if it reaches zero.
|
* Decrement the reference count of json_object and free if it reaches zero.
|
||||||
@@ -192,7 +192,7 @@ JSON_EXPORT struct json_object* json_object_retain(struct json_object *obj);
|
|||||||
* @param obj the json_object instance
|
* @param obj the json_object instance
|
||||||
* @returns 1 if the object was freed.
|
* @returns 1 if the object was freed.
|
||||||
*/
|
*/
|
||||||
JSON_EXPORT int json_object_release(struct json_object *obj);
|
JSON_EXPORT int json_object_put(struct json_object *obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the json_object is of a given type
|
* Check if the json_object is of a given type
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ int json_pointer_set(struct json_object **obj, const char *path, struct json_obj
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path[0] == '\0') {
|
if (path[0] == '\0') {
|
||||||
json_object_release(*obj);
|
json_object_put(*obj);
|
||||||
*obj = value;
|
*obj = value;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ int json_pointer_setf(struct json_object **obj, struct json_object *value, const
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if (path_copy[0] == '\0') {
|
if (path_copy[0] == '\0') {
|
||||||
json_object_release(*obj);
|
json_object_put(*obj);
|
||||||
*obj = value;
|
*obj = value;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ static void json_tokener_reset_level(struct json_tokener *tok, int depth)
|
|||||||
{
|
{
|
||||||
tok->stack[depth].state = json_tokener_state_eatws;
|
tok->stack[depth].state = json_tokener_state_eatws;
|
||||||
tok->stack[depth].saved_state = json_tokener_state_start;
|
tok->stack[depth].saved_state = json_tokener_state_start;
|
||||||
json_object_release(tok->stack[depth].current);
|
json_object_put(tok->stack[depth].current);
|
||||||
tok->stack[depth].current = NULL;
|
tok->stack[depth].current = NULL;
|
||||||
free(tok->stack[depth].obj_field_name);
|
free(tok->stack[depth].obj_field_name);
|
||||||
tok->stack[depth].obj_field_name = NULL;
|
tok->stack[depth].obj_field_name = NULL;
|
||||||
@@ -178,7 +178,7 @@ struct json_object* json_tokener_parse_verbose(const char *str,
|
|||||||
*error = tok->err;
|
*error = tok->err;
|
||||||
if(tok->err != json_tokener_success) {
|
if(tok->err != json_tokener_success) {
|
||||||
if (obj != NULL)
|
if (obj != NULL)
|
||||||
json_object_release(obj);
|
json_object_put(obj);
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +378,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
|
|
||||||
case json_tokener_state_finish:
|
case json_tokener_state_finish:
|
||||||
if(tok->depth == 0) goto out;
|
if(tok->depth == 0) goto out;
|
||||||
obj = json_object_retain(current);
|
obj = json_object_get(current);
|
||||||
json_tokener_reset_level(tok, tok->depth);
|
json_tokener_reset_level(tok, tok->depth);
|
||||||
tok->depth--;
|
tok->depth--;
|
||||||
goto redo_char;
|
goto redo_char;
|
||||||
@@ -959,7 +959,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
|
|
||||||
if (tok->err == json_tokener_success)
|
if (tok->err == json_tokener_success)
|
||||||
{
|
{
|
||||||
json_object *ret = json_object_retain(current);
|
json_object *ret = json_object_get(current);
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
/* Partially reset, so we parse additional objects on subsequent calls. */
|
/* Partially reset, so we parse additional objects on subsequent calls. */
|
||||||
|
|||||||
Reference in New Issue
Block a user