diff mbox series

[ovs-dev,12/13] json: New function json_nullable_clone().

Message ID 20171007004458.5788-13-blp@ovn.org
State Accepted
Headers show
Series clustering implementation, part 1 | expand

Commit Message

Ben Pfaff Oct. 7, 2017, 12:44 a.m. UTC
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 include/openvswitch/json.h | 1 +
 lib/json.c                 | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Russell Bryant Oct. 9, 2017, 8:05 p.m. UTC | #1
On Fri, Oct 6, 2017 at 8:44 PM, Ben Pfaff <blp@ovn.org> wrote:
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---
>  include/openvswitch/json.h | 1 +
>  lib/json.c                 | 8 +++++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)

Acked-by: Russell Bryant <russell@ovn.org>
diff mbox series

Patch

diff --git a/include/openvswitch/json.h b/include/openvswitch/json.h
index 83775ed0efdf..edf53e594eb0 100644
--- a/include/openvswitch/json.h
+++ b/include/openvswitch/json.h
@@ -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);
diff --git a/lib/json.c b/lib/json.c
index 40c8f718db72..b98e60f87f4b 100644
--- a/lib/json.c
+++ b/lib/json.c
@@ -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.
@@ -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)
 {