Remove str_dup_safe() in favour of xstrdup() from libbb.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 4 Nov 2009 02:13:22 +0000 (02:13 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 4 Nov 2009 02:13:22 +0000 (02:13 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@253 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/nv_pair.c
libopkg/pkg.c
libopkg/pkg_src.c
libopkg/str_util.c
libopkg/str_util.h

index 8cfb06a047dc645f1ba6ea2792c234e0ae731025..e475a7c55f3d7d3773c9f06bcfd03bdb87ece7da 100644 (file)
 #include "includes.h"
 
 #include "nv_pair.h"
-#include "str_util.h"
+#include "libbb/libbb.h"
 
 int nv_pair_init(nv_pair_t *nv_pair, const char *name, const char *value)
 {
 
-    nv_pair->name = str_dup_safe(name);
-    nv_pair->value = str_dup_safe(value);
+    nv_pair->name = xstrdup(name);
+    nv_pair->value = xstrdup(value);
 
     return 0;
 }
index e36a38133c688165f71a2b19d9045637c46c24e6..e3e6c049b58ab46bb0772fabda58466648f1109d 100644 (file)
@@ -29,6 +29,7 @@
 #include "opkg_message.h"
 #include "opkg_utils.h"
 
+#include "libbb/libbb.h"
 #include "sprintf_alloc.h"
 #include "file_util.h"
 #include "str_util.h"
@@ -330,15 +331,15 @@ int pkg_merge(pkg_t *oldpkg, pkg_t *newpkg, int set_status)
      if (!oldpkg->dest)
          oldpkg->dest = newpkg->dest;
      if (!oldpkg->architecture)
-         oldpkg->architecture = str_dup_safe(newpkg->architecture);
+         oldpkg->architecture = xstrdup(newpkg->architecture);
      if (!oldpkg->arch_priority)
          oldpkg->arch_priority = newpkg->arch_priority;
      if (!oldpkg->section)
-         oldpkg->section = str_dup_safe(newpkg->section);
+         oldpkg->section = xstrdup(newpkg->section);
      if(!oldpkg->maintainer)
-         oldpkg->maintainer = str_dup_safe(newpkg->maintainer);
+         oldpkg->maintainer = xstrdup(newpkg->maintainer);
      if(!oldpkg->description)
-         oldpkg->description = str_dup_safe(newpkg->description);
+         oldpkg->description = xstrdup(newpkg->description);
      if (set_status) {
          /* merge the state_flags from the new package */
          oldpkg->state_want = newpkg->state_want;
@@ -408,28 +409,28 @@ int pkg_merge(pkg_t *oldpkg, pkg_t *newpkg, int set_status)
      }
 
      if (!oldpkg->filename)
-         oldpkg->filename = str_dup_safe(newpkg->filename);
+         oldpkg->filename = xstrdup(newpkg->filename);
      if (0)
      fprintf(stdout, "pkg=%s old local_filename=%s new local_filename=%s\n", 
             oldpkg->name, oldpkg->local_filename, newpkg->local_filename);
      if (!oldpkg->local_filename)
-         oldpkg->local_filename = str_dup_safe(newpkg->local_filename);
+         oldpkg->local_filename = xstrdup(newpkg->local_filename);
      if (!oldpkg->tmp_unpack_dir)
-         oldpkg->tmp_unpack_dir = str_dup_safe(newpkg->tmp_unpack_dir);
+         oldpkg->tmp_unpack_dir = xstrdup(newpkg->tmp_unpack_dir);
      if (!oldpkg->md5sum)
-         oldpkg->md5sum = str_dup_safe(newpkg->md5sum);
+         oldpkg->md5sum = xstrdup(newpkg->md5sum);
 #if defined HAVE_SHA256
      if (!oldpkg->sha256sum)
-         oldpkg->sha256sum = str_dup_safe(newpkg->sha256sum);
+         oldpkg->sha256sum = xstrdup(newpkg->sha256sum);
 #endif
      if (!oldpkg->size)
-         oldpkg->size = str_dup_safe(newpkg->size);
+         oldpkg->size = xstrdup(newpkg->size);
      if (!oldpkg->installed_size)
-         oldpkg->installed_size = str_dup_safe(newpkg->installed_size);
+         oldpkg->installed_size = xstrdup(newpkg->installed_size);
      if (!oldpkg->priority)
-         oldpkg->priority = str_dup_safe(newpkg->priority);
+         oldpkg->priority = xstrdup(newpkg->priority);
      if (!oldpkg->source)
-         oldpkg->source = str_dup_safe(newpkg->source);
+         oldpkg->source = xstrdup(newpkg->source);
      if (nv_pair_list_empty(&oldpkg->conffiles)){
          list_splice_init(&newpkg->conffiles.head, &oldpkg->conffiles.head);
          conffile_list_init(&newpkg->conffiles);
index ec9c5f29f8abefd44b7a2628c165f366502d1526..b8679c3a3d5054487f99fa086eb073f181bbb326 100644 (file)
 #include "includes.h"
 
 #include "pkg_src.h"
-#include "str_util.h"
+#include "libbb/libbb.h"
 
 int pkg_src_init(pkg_src_t *src, const char *name, const char *base_url, const char *extra_data, int gzip)
 {
     src->gzip = gzip;
-    src->name = str_dup_safe (name);
-    src->value = str_dup_safe (base_url);
+    src->name = xstrdup(name);
+    src->value = xstrdup(base_url);
     if (extra_data)
-       src->extra_data = str_dup_safe (extra_data);
+       src->extra_data = xstrdup(extra_data);
     else
        src->extra_data = NULL;
     return 0;
@@ -39,5 +39,3 @@ void pkg_src_deinit(pkg_src_t *src)
     if (src->extra_data)
        free (src->extra_data);
 }
-
-
index 7e998f280ce80d3b350154f6e23e57f00b3f7912..d583b7a8ee6f895e09564c8a14dca1f3ff284ba3 100644 (file)
@@ -65,9 +65,3 @@ int str_toupper(char *str)
 
     return 0;
 }
-
-char *str_dup_safe(const char *str)
-{
-    return str ? strdup(str) : NULL;
-}
-
index f332681e66ddbb492dc8515fb4a5ee1514e78b44..832654fc3c43e6f16bceb7b85ead05dc3fac1f44 100644 (file)
@@ -23,6 +23,5 @@ int str_ends_with(const char *str, const char *suffix);
 int str_chomp(char *str);
 int str_tolower(char *str);
 int str_toupper(char *str);
-char *str_dup_safe(const char *str);
 
 #endif