summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-05-06 14:51:48 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-05-06 15:09:39 +0300
commit63dcd3d4973906eccd76129d194fabea34faece9 (patch)
treeb6775e81e74a242b97d75abfbb0d5128c97934ff
parent118fba22950c35ef296c93b992746c9137a67f23 (diff)
downloadlibrpm-tizen-63dcd3d4973906eccd76129d194fabea34faece9.tar.gz
librpm-tizen-63dcd3d4973906eccd76129d194fabea34faece9.tar.bz2
librpm-tizen-63dcd3d4973906eccd76129d194fabea34faece9.zip
Minor cleanup to rpmfsNew()
- use xcalloc() to ensure clean state, no need to manually do it all - group non-conditional and conditional operations together
-rw-r--r--lib/rpmfs.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/rpmfs.c b/lib/rpmfs.c
index 50ed6d9f4..f5d478817 100644
--- a/lib/rpmfs.c
+++ b/lib/rpmfs.c
@@ -13,18 +13,16 @@ struct rpmfs_s {
int allocatedReplaced;
};
-rpmfs rpmfsNew(unsigned int fc, rpmElementType type) {
- rpmfs fs = xmalloc(sizeof(*fs));
+rpmfs rpmfsNew(unsigned int fc, rpmElementType type)
+{
+ rpmfs fs = xcalloc(1, sizeof(*fs));
fs->fc = fc;
- fs->replaced = NULL;
- fs->states = NULL;
+ fs->actions = xmalloc(fc * sizeof(*fs->actions));
+ memset(fs->actions, FA_UNKNOWN, fc * sizeof(*fs->actions));
if (type == TR_ADDED) {
fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc);
}
- fs->actions = xmalloc(fc * sizeof(*fs->actions));
- memset(fs->actions, FA_UNKNOWN, fc * sizeof(*fs->actions));
- fs->numReplaced = fs->allocatedReplaced = 0;
return fs;
}