From patchwork Sat Oct 7 00:44:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 822862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y87HQ0dgZz9t5Y for ; Sat, 7 Oct 2017 11:51:30 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4CF6FBF0; Sat, 7 Oct 2017 00:45:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp2.linuxfoundation.org (smtp2.linux-foundation.org [172.17.192.36]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D59D3BE9 for ; Sat, 7 Oct 2017 00:45:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp2.linuxfoundation.org (Postfix) with ESMTPS id 4AD8D1DABB for ; Sat, 7 Oct 2017 00:45:45 +0000 (UTC) X-Originating-IP: 173.228.112.34 Received: from sigabrt.gateway.sonic.net (173-228-112-34.dsl.dynamic.fusionbroadband.com [173.228.112.34]) (Authenticated sender: blp@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 0F058A80C0; Sat, 7 Oct 2017 02:45:41 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 6 Oct 2017 17:44:57 -0700 Message-Id: <20171007004458.5788-13-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171007004458.5788-1-blp@ovn.org> References: <20171007004458.5788-1-blp@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp2.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 12/13] json: New function json_nullable_clone(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Ben Pfaff Acked-by: Russell Bryant --- include/openvswitch/json.h | 1 + lib/json.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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) {