diff options
author | Ben Pfaff <blp@ovn.org> | 2018-03-23 15:46:58 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-03-31 12:22:58 -0700 |
commit | 828129d9271da18c2742648aa910e1fe399bb8db (patch) | |
tree | b6c38580b22179dc7c7efd4c030aed5b9ff89b38 /include/openvswitch | |
parent | 056caea89bffe5f27000944c0ed5aaa6f7a2d852 (diff) | |
download | openvswitch-828129d9271da18c2742648aa910e1fe399bb8db.tar.gz |
json: Avoid extra memory allocation and string copy parsing object members.
Until now, every time the JSON parser added an object member, it made an
extra copy of the member name and then freed the original copy. This is
wasteful, so this commit eliminates the extra copy.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Diffstat (limited to 'include/openvswitch')
-rw-r--r-- | include/openvswitch/json.h | 1 | ||||
-rw-r--r-- | include/openvswitch/shash.h | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/include/openvswitch/json.h b/include/openvswitch/json.h index 61b9a02cf..bcf6a2782 100644 --- a/include/openvswitch/json.h +++ b/include/openvswitch/json.h @@ -91,6 +91,7 @@ struct json *json_array_create_3(struct json *, struct json *, struct json *); struct json *json_object_create(void); void json_object_put(struct json *, const char *name, struct json *value); +void json_object_put_nocopy(struct json *, char *name, struct json *value); void json_object_put_string(struct json *, const char *name, const char *value); void json_object_put_format(struct json *, diff --git a/include/openvswitch/shash.h b/include/openvswitch/shash.h index afc482364..c249e13e1 100644 --- a/include/openvswitch/shash.h +++ b/include/openvswitch/shash.h @@ -62,6 +62,7 @@ struct shash_node *shash_add_nocopy(struct shash *, char *, const void *); bool shash_add_once(struct shash *, const char *, const void *); void shash_add_assert(struct shash *, const char *, const void *); void *shash_replace(struct shash *, const char *, const void *data); +void *shash_replace_nocopy(struct shash *, char *name, const void *data); void shash_delete(struct shash *, struct shash_node *); char *shash_steal(struct shash *, struct shash_node *); struct shash_node *shash_find(const struct shash *, const char *); |