summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-08-01 14:19:54 -0700
committerAllan McRae <allan@archlinux.org>2014-08-04 14:23:58 +1000
commit2025279eb64c397e408baab7ff686624604f415a (patch)
tree86534a508550250a4e583220b844e09d46a86bb5
parentd981f93f18449e2cb7b67bfb417aac4737c84b57 (diff)
downloadpacman-2025279eb64c397e408baab7ff686624604f415a.tar.xz
replace strdup with STRDUP
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--lib/libalpm/diskspace.c6
-rw-r--r--lib/libalpm/handle.c10
-rw-r--r--lib/libalpm/package.c2
3 files changed, 7 insertions, 11 deletions
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 606f2dcc..af87f755 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -112,7 +112,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((mnt = getmntent(fp))) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- mp->mount_dir = strdup(mnt->mnt_dir);
+ STRDUP(mp->mount_dir, mnt->mnt_dir, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -135,7 +135,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((ret = getmntent(fp, &mnt)) == 0) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- mp->mount_dir = strdup(mnt->mnt_mountp);
+ STRDUP(mp->mount_dir, mnt->mnt_mountp, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -162,7 +162,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
for(; entries-- > 0; fsp++) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- mp->mount_dir = strdup(fsp->f_mntonname);
+ STRDUP(mp->mount_dir, fsp->f_mntonname, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));
#if defined(HAVE_GETMNTINFO_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FLAG)
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 0efc0a96..fdd269b1 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -417,7 +417,7 @@ int SYMEXPORT alpm_option_set_logfile(alpm_handle_t *handle, const char *logfile
return -1;
}
- handle->logfile = strdup(logfile);
+ STRDUP(handle->logfile, logfile, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
/* free the old logfile path string, and close the stream so logaction
* will reopen a new stream on the new logfile */
@@ -443,7 +443,7 @@ int SYMEXPORT alpm_option_set_gpgdir(alpm_handle_t *handle, const char *gpgdir)
if(handle->gpgdir) {
FREE(handle->gpgdir);
}
- handle->gpgdir = strdup(gpgdir);
+ STRDUP(handle->gpgdir, gpgdir, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
_alpm_log(handle, ALPM_LOG_DEBUG, "option 'gpgdir' = %s\n", handle->gpgdir);
return 0;
@@ -549,11 +549,7 @@ int SYMEXPORT alpm_option_set_arch(alpm_handle_t *handle, const char *arch)
{
CHECK_HANDLE(handle, return -1);
if(handle->arch) FREE(handle->arch);
- if(arch) {
- handle->arch = strdup(arch);
- } else {
- handle->arch = NULL;
- }
+ STRDUP(handle->arch, arch, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
return 0;
}
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index e8863f68..a69f454c 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -613,7 +613,7 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
newpkg->infolevel = pkg->infolevel;
newpkg->origin = pkg->origin;
if(newpkg->origin == ALPM_PKG_FROM_FILE) {
- newpkg->origin_data.file = strdup(pkg->origin_data.file);
+ STRDUP(newpkg->origin_data.file, pkg->origin_data.file, goto cleanup);
} else {
newpkg->origin_data.db = pkg->origin_data.db;
}