mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-11 13:30:02 -05:00
json: Drop refcounting of json objects
We don't actually use the refcounting bits. Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
This commit is contained in:
parent
8f45d83bdb
commit
e3148f9ac2
4 changed files with 33 additions and 37 deletions
|
|
@ -300,7 +300,7 @@ pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char
|
|||
break;
|
||||
}
|
||||
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
@ -324,12 +324,12 @@ int pa_format_info_get_prop_int(const pa_format_info *f, const char *key, int *v
|
|||
|
||||
if (pa_json_object_get_type(o) != PA_JSON_TYPE_INT) {
|
||||
pa_log_debug("Format info property '%s' type is not int.", key);
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
return -PA_ERR_INVALID;
|
||||
}
|
||||
|
||||
*v = pa_json_object_get_int(o);
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ out:
|
|||
if (ret < 0)
|
||||
pa_log_debug("Format info property '%s' is not a valid int range.", key);
|
||||
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -423,7 +423,7 @@ out:
|
|||
if (ret < 0)
|
||||
pa_log_debug("Format info property '%s' is not a valid int array.", key);
|
||||
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -447,12 +447,12 @@ int pa_format_info_get_prop_string(const pa_format_info *f, const char *key, cha
|
|||
|
||||
if (pa_json_object_get_type(o) != PA_JSON_TYPE_STRING) {
|
||||
pa_log_debug("Format info property '%s' type is not string.", key);
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
return -PA_ERR_INVALID;
|
||||
}
|
||||
|
||||
*v = pa_xstrdup(pa_json_object_get_string(o));
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -500,7 +500,7 @@ out:
|
|||
if (ret < 0)
|
||||
pa_log_debug("Format info property '%s' is not a valid string array.", key);
|
||||
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -675,9 +675,9 @@ static int pa_format_info_prop_compatible(const char *one, const char *two) {
|
|||
|
||||
out:
|
||||
if (o1)
|
||||
pa_json_object_unref(o1);
|
||||
pa_json_object_free(o1);
|
||||
if (o2)
|
||||
pa_json_object_unref(o2);
|
||||
pa_json_object_free(o2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,11 @@
|
|||
#include <pulse/xmalloc.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/hashmap.h>
|
||||
#include <pulsecore/refcnt.h>
|
||||
#include <pulsecore/strbuf.h>
|
||||
|
||||
#define MAX_NESTING_DEPTH 20 /* Arbitrary number to make sure we don't have a stack overflow */
|
||||
|
||||
struct pa_json_object {
|
||||
PA_REFCNT_DECLARE;
|
||||
pa_json_type type;
|
||||
|
||||
union {
|
||||
|
|
@ -309,7 +307,7 @@ static const char *parse_object(const char *str, pa_json_object *obj, unsigned i
|
|||
pa_json_object *name = NULL, *value = NULL;
|
||||
|
||||
obj->object_values = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func,
|
||||
pa_xfree, (pa_free_cb_t) pa_json_object_unref);
|
||||
pa_xfree, (pa_free_cb_t) pa_json_object_free);
|
||||
|
||||
while (*str != '}') {
|
||||
str++; /* Consume leading '{' or ',' */
|
||||
|
|
@ -330,7 +328,7 @@ static const char *parse_object(const char *str, pa_json_object *obj, unsigned i
|
|||
}
|
||||
|
||||
pa_hashmap_put(obj->object_values, pa_xstrdup(pa_json_object_get_string(name)), value);
|
||||
pa_json_object_unref(name);
|
||||
pa_json_object_free(name);
|
||||
|
||||
name = NULL;
|
||||
value = NULL;
|
||||
|
|
@ -349,9 +347,9 @@ error:
|
|||
obj->object_values = NULL;
|
||||
|
||||
if (name)
|
||||
pa_json_object_unref(name);
|
||||
pa_json_object_free(name);
|
||||
if (value)
|
||||
pa_json_object_unref(value);
|
||||
pa_json_object_free(value);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -390,7 +388,7 @@ static const char *parse_array(const char *str, pa_json_object *obj, unsigned in
|
|||
return str;
|
||||
|
||||
error:
|
||||
pa_idxset_free(obj->array_values, (pa_free_cb_t) pa_json_object_unref);
|
||||
pa_idxset_free(obj->array_values, (pa_free_cb_t) pa_json_object_free);
|
||||
obj->array_values = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -467,7 +465,7 @@ static const char* parse_value(const char *str, const char *end, pa_json_object
|
|||
return str;
|
||||
|
||||
error:
|
||||
pa_json_object_unref(o);
|
||||
pa_json_object_free(o);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -484,7 +482,7 @@ pa_json_object* pa_json_parse(const char *str) {
|
|||
|
||||
if (*str != '\0') {
|
||||
pa_log("Unable to parse complete JSON string, remainder is: %s", str);
|
||||
pa_json_object_unref(obj);
|
||||
pa_json_object_free(obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -495,9 +493,7 @@ pa_json_type pa_json_object_get_type(const pa_json_object *obj) {
|
|||
return obj->type;
|
||||
}
|
||||
|
||||
void pa_json_object_unref(pa_json_object *obj) {
|
||||
if (PA_REFCNT_DEC(obj) > 0)
|
||||
return;
|
||||
void pa_json_object_free(pa_json_object *obj) {
|
||||
|
||||
switch (pa_json_object_get_type(obj)) {
|
||||
case PA_JSON_TYPE_INIT:
|
||||
|
|
@ -516,7 +512,7 @@ void pa_json_object_unref(pa_json_object *obj) {
|
|||
break;
|
||||
|
||||
case PA_JSON_TYPE_ARRAY:
|
||||
pa_idxset_free(obj->array_values, (pa_free_cb_t) pa_json_object_unref);
|
||||
pa_idxset_free(obj->array_values, (pa_free_cb_t) pa_json_object_free);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ typedef struct pa_json_object pa_json_object;
|
|||
|
||||
pa_json_object* pa_json_parse(const char *str);
|
||||
pa_json_type pa_json_object_get_type(const pa_json_object *obj);
|
||||
void pa_json_object_unref(pa_json_object *obj);
|
||||
void pa_json_object_free(pa_json_object *obj);
|
||||
|
||||
/* All pointer members that are returned are valid while the corresponding object is valid */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue