From 923f73d334e7969a814d09cbba3a2a416ac7b0dc Mon Sep 17 00:00:00 2001 From: "graham.gower" Date: Wed, 4 Nov 2009 02:13:22 +0000 Subject: [PATCH] Remove str_dup_safe() in favour of xstrdup() from libbb. git-svn-id: http://opkg.googlecode.com/svn/trunk@253 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- libopkg/nv_pair.c | 6 +++--- libopkg/pkg.c | 27 ++++++++++++++------------- libopkg/pkg_src.c | 10 ++++------ libopkg/str_util.c | 6 ------ libopkg/str_util.h | 1 - 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/libopkg/nv_pair.c b/libopkg/nv_pair.c index 8cfb06a..e475a7c 100644 --- a/libopkg/nv_pair.c +++ b/libopkg/nv_pair.c @@ -18,13 +18,13 @@ #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; } diff --git a/libopkg/pkg.c b/libopkg/pkg.c index e36a381..e3e6c04 100644 --- a/libopkg/pkg.c +++ b/libopkg/pkg.c @@ -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); diff --git a/libopkg/pkg_src.c b/libopkg/pkg_src.c index ec9c5f2..b8679c3 100644 --- a/libopkg/pkg_src.c +++ b/libopkg/pkg_src.c @@ -18,15 +18,15 @@ #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); } - - diff --git a/libopkg/str_util.c b/libopkg/str_util.c index 7e998f2..d583b7a 100644 --- a/libopkg/str_util.c +++ b/libopkg/str_util.c @@ -65,9 +65,3 @@ int str_toupper(char *str) return 0; } - -char *str_dup_safe(const char *str) -{ - return str ? strdup(str) : NULL; -} - diff --git a/libopkg/str_util.h b/libopkg/str_util.h index f332681..832654f 100644 --- a/libopkg/str_util.h +++ b/libopkg/str_util.h @@ -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 -- 2.25.1