NetBSD Problem Report #46723

From www@NetBSD.org  Thu Jul 19 11:38:02 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id B79C863B882
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 19 Jul 2012 11:38:02 +0000 (UTC)
Message-Id: <20120719113801.DF26B63B85F@www.NetBSD.org>
Date: Thu, 19 Jul 2012 11:38:01 +0000 (UTC)
From: xtraeme@gmail.com
Reply-To: xtraeme@gmail.com
To: gnats-bugs@NetBSD.org
Subject: proplib: new prop_array_add_cstring{,_nocopy} util funcs
X-Send-Pr-Version: www-1.0

>Number:         46723
>Category:       lib
>Synopsis:       proplib: new prop_array_add_cstring{,_nocopy} util funcs
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    pgoyette
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 19 11:40:00 +0000 2012
>Closed-Date:    Tue May 31 09:30:34 +0000 2016
>Last-Modified:  Tue May 31 09:30:34 +0000 2016
>Originator:     Juan RP
>Release:        void
>Organization:
void
>Environment:
void
>Description:
Add the following useful functions to proplib:

- prop_array_add_cstring
- prop_array_add_cstring_nocopy

This saves a bit of code duplication in some cases. I'll submit the patch in an upcoming email.
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Juan RP <xtraeme@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/46723: proplib: new prop_array_add_cstring{,_nocopy} util
 funcs
Date: Thu, 19 Jul 2012 13:42:53 +0200

 From 819b861bacc048a36c66510b563c4da7e9349912 Mon Sep 17 00:00:00 2001
 From: Juan RP <xtraeme@gmail.com>
 Date: Thu, 19 Jul 2012 13:28:28 +0200
 Subject: [PATCH] proplib: add prop_array_add_cstring{,_nocopy} to
  prop_array_util(3).

 ---
  common/lib/libprop/prop_array_util.3 | 13 +++++++++++--
  common/lib/libprop/prop_array_util.c | 15 +++++++++++++++
  2 files changed, 26 insertions(+), 2 deletions(-)

 diff --git a/common/lib/libprop/prop_array_util.3 b/common/lib/libprop/prop_array_util.3
 index 89323a5..8452064 100644
 --- a/common/lib/libprop/prop_array_util.3
 +++ b/common/lib/libprop/prop_array_util.3
 @@ -27,7 +27,7 @@
  .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  .\" POSSIBILITY OF SUCH DAMAGE.
  .\"
 -.Dd March 12, 2011
 +.Dd July 19, 2012
  .Dt PROP_ARRAY_UTIL 3
  .Os
  .Sh NAME
 @@ -58,8 +58,10 @@
  .Nm prop_array_add_uint32 ,
  .Nm prop_array_add_int64 ,
  .Nm prop_array_add_uint64 ,
 +.Nm prop_array_add_cstring ,
  .Nm prop_array_get_cstring ,
  .Nm prop_array_set_cstring ,
 +.Nm prop_array_add_cstring_nocopy ,
  .Nm prop_array_get_cstring_nocopy ,
  .Nm prop_array_set_cstring_nocopy ,
  .Nm prop_array_add_and_rel
 @@ -153,6 +155,8 @@
  .Fn prop_array_add_uint64 "prop_array_t dict" "uint64_t val"
  .\"
  .Ft bool
 +.Fn prop_array_add_cstring "prop_array_t dict" "const char *cp"
 +.Ft bool
  .Fn prop_array_get_cstring "prop_array_t dict" "unsigned int indx" \
      "char **strp"
  .Ft bool
 @@ -160,6 +164,8 @@
      "const char *str"
  .\"
  .Ft bool
 +.Fn prop_array_add_cstring_nocopy "prop_array_t dict" "const char *cp"
 +.Ft bool
  .Fn prop_array_get_cstring_nocopy "prop_array_t dict" \
      "unsigned int indx" "const char **strp"
  .Ft bool
 @@ -181,13 +187,16 @@ value type.
  The setters handle object creation and release for the caller.
  .Pp
  The
 +.Fn prop_array_add_cstring
 +and
  .Fn prop_array_get_cstring
 -function returns dynamically allocated memory.
 +functions return dynamically allocated memory.
  See
  .Xr prop_string 3
  for more information.
  .Pp
  The
 +.Fn prop_array_add_cstring_nocopy ,
  .Fn prop_array_get_cstring_nocopy
  and
  .Fn prop_array_set_cstring_nocopy
 diff --git a/common/lib/libprop/prop_array_util.c b/common/lib/libprop/prop_array_util.c
 index 8515bd5..131def4 100644
 --- a/common/lib/libprop/prop_array_util.c
 +++ b/common/lib/libprop/prop_array_util.c
 @@ -201,6 +201,21 @@ TEMPLATE(64)
  #undef TEMPLATE

  #define	TEMPLATE(variant, qualifier)					\
 +bool									\
 +prop_array_add_cstring ## variant (prop_array_t array,			\
 +					const char *cp)			\
 +{									\
 +	prop_string_t str;						\
 +	bool rv;							\
 +									\
 +	str = prop_string_create_cstring ## variant (cp);		\
 +	if (str == NULL)						\
 +		return false;						\
 +	rv = prop_array_add(array, str);				\
 +	prop_object_release(str);					\
 +	return rv;							\
 +}									\
 +									\
  bool								        \
  prop_array_get_cstring ## variant (prop_array_t array,		        \
  					unsigned int indx,		\
 -- 
 1.7.11.2

Responsible-Changed-From-To: lib-bug-people->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Tue, 31 May 2016 08:07:42 +0000
Responsible-Changed-Why:
I'm working on it.


State-Changed-From-To: open->analyzed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 31 May 2016 08:07:42 +0000
State-Changed-Why:
I'm working on it.


From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46723 CVS commit: src/common
Date: Tue, 31 May 2016 09:29:26 +0000

 Module Name:	src
 Committed By:	pgoyette
 Date:		Tue May 31 09:29:26 UTC 2016

 Modified Files:
 	src/common/include/prop: prop_array.h
 	src/common/lib/libprop: prop_array_util.3 prop_array_util.c

 Log Message:
 Add prop_array_add_cstring{,_no_copy} utility functions as suggested in
 PR lib/46723 using the patch provided.  (Header file updates are mine.)


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.14 src/common/include/prop/prop_array.h
 cvs rdiff -u -r1.7 -r1.8 src/common/lib/libprop/prop_array_util.3
 cvs rdiff -u -r1.4 -r1.5 src/common/lib/libprop/prop_array_util.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: analyzed->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 31 May 2016 09:30:34 +0000
State-Changed-Why:
Patch committed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.