Skip to content

Commit

Permalink
json: New function json_nullable_clone().
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Russell Bryant <[email protected]>
  • Loading branch information
blp committed Oct 24, 2017
1 parent ffa3493 commit d697750
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/openvswitch/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ int64_t json_integer(const struct json *);

struct json *json_deep_clone(const struct json *);
struct json *json_clone(const struct json *);
struct json *json_nullable_clone(const struct json *);
void json_destroy(struct json *);

size_t json_hash(const struct json *, size_t basis);
Expand Down
8 changes: 7 additions & 1 deletion lib/json.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2014, 2015 Nicira, Inc.
* Copyright (c) 2009-2012, 2014-2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -430,6 +430,12 @@ json_clone(const struct json *json_)
return json;
}

struct json *
json_nullable_clone(const struct json *json)
{
return json ? json_clone(json) : NULL;
}

static struct json *
json_clone_object(const struct shash *object)
{
Expand Down

0 comments on commit d697750

Please sign in to comment.