NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/46723: proplib: new prop_array_add_cstring{,_nocopy} util funcs



The following reply was made to PR lib/46723; it has been noted by GNATS.

From: Juan RP <xtraeme%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
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@localhost>
 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
 


Home | Main Index | Thread Index | Old Index