summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2005-03-28 15:15:03 +0000
committerJason Woodward2005-03-28 15:15:03 +0000
commit8ffe7b89652fd774cf3a5581878ae048e5559a83 (patch)
tree5398c7a9fbe801240b09fac4408f23736131ce3b
parentde2e93bf04e4ec7afc912043c8467369408a5e6b (diff)
downloadslapt-get-8ffe7b89652fd774cf3a5581878ae048e5559a83.tar.gz
added copy_pkg() to package.[ch] instead of using memcpy() in the transaction code, so free_transaction() calls free_pkg() making all usage of pkg_info_t objects uniform
-rw-r--r--ChangeLog3
-rw-r--r--src/package.c9
-rw-r--r--src/package.h2
-rw-r--r--src/transaction.c37
4 files changed, 28 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index db4b9f8..e90d4d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
0.9.9j Mar 28, 2005
+ * added copy_pkg() to package.[ch] instead of using memcpy() in the transaction
+ code, so free_transaction() calls free_pkg() making all usage of pkg_info_t
+ objects uniform
* translation updates
* fixed precision error in curl progress callback, d/l stats now report
correct percentage
diff --git a/src/package.c b/src/package.c
index d615789..dda4bc3 100644
--- a/src/package.c
+++ b/src/package.c
@@ -2119,3 +2119,12 @@ static pkg_info_t *find_or_requirement(struct pkg_list *avail_pkgs,struct pkg_li
return pkg;
}
+
+pkg_info_t *copy_pkg(pkg_info_t *dst,pkg_info_t *src){
+ dst = memcpy(dst,src, sizeof *src);
+ dst->suggests = strndup(src->suggests, strlen(src->suggests));
+ dst->conflicts = strndup(src->conflicts, strlen(src->conflicts));
+ dst->required = strndup(src->required, strlen(src->required));
+ return dst;
+}
+
diff --git a/src/package.h b/src/package.h
index c393acd..b62bcd7 100644
--- a/src/package.h
+++ b/src/package.h
@@ -164,3 +164,5 @@ void clean_pkg_dir(const char *dir_name);
/* clean out old outdated packages in the cache */
void purge_old_cached_pkgs(const rc_config *global_config,char *dir_name, struct pkg_list *avail_pkgs);
+/* make a copy of a package (needs to be freed with free_pkg) */
+pkg_info_t *copy_pkg(pkg_info_t *dst,pkg_info_t *src);
diff --git a/src/transaction.c b/src/transaction.c
index 99b807e..583f088 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -325,16 +325,14 @@ void add_install_to_transaction(transaction_t *tran,pkg_info_t *pkg){
tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count] = slapt_malloc(
sizeof *tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count]
);
- tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count] = memcpy(
+ tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count] = copy_pkg(
tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count],
- pkg,
- sizeof *pkg
+ pkg
);
queue_add_install(tran->queue,tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count]);
+ add_suggestion(tran,tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count]);
++tran->install_pkgs->pkg_count;
-
- add_suggestion(tran,pkg);
}
}
@@ -360,10 +358,9 @@ void add_remove_to_transaction(transaction_t *tran,pkg_info_t *pkg){
tran->remove_pkgs->pkgs[tran->remove_pkgs->pkg_count] = slapt_malloc(
sizeof *tran->remove_pkgs->pkgs[tran->remove_pkgs->pkg_count]
);
- tran->remove_pkgs->pkgs[tran->remove_pkgs->pkg_count] = memcpy(
+ tran->remove_pkgs->pkgs[tran->remove_pkgs->pkg_count] = copy_pkg(
tran->remove_pkgs->pkgs[tran->remove_pkgs->pkg_count],
- pkg,
- sizeof *pkg
+ pkg
);
++tran->remove_pkgs->pkg_count;
}
@@ -391,10 +388,9 @@ void add_exclude_to_transaction(transaction_t *tran,pkg_info_t *pkg){
tran->exclude_pkgs->pkgs[tran->exclude_pkgs->pkg_count] = slapt_malloc(
sizeof *tran->exclude_pkgs->pkgs[tran->exclude_pkgs->pkg_count]
);
- tran->exclude_pkgs->pkgs[tran->exclude_pkgs->pkg_count] = memcpy(
+ tran->exclude_pkgs->pkgs[tran->exclude_pkgs->pkg_count] = copy_pkg(
tran->exclude_pkgs->pkgs[tran->exclude_pkgs->pkg_count],
- pkg,
- sizeof *pkg
+ pkg
);
++tran->exclude_pkgs->pkg_count;
}
@@ -431,15 +427,13 @@ void add_upgrade_to_transaction(
sizeof *tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->upgrade
);
- tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->installed = memcpy(
+ tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->installed = copy_pkg(
tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->installed,
- installed_pkg,
- sizeof *installed_pkg
+ installed_pkg
);
- tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->upgrade = memcpy(
+ tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->upgrade = copy_pkg(
tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->upgrade,
- upgrade_pkg,
- sizeof *upgrade_pkg
+ upgrade_pkg
);
queue_add_upgrade(
@@ -488,15 +482,13 @@ void free_transaction(transaction_t *tran){
unsigned int i;
for(i = 0;i < tran->install_pkgs->pkg_count; i++){
- /* no free_pkg() b/c the *pkg is all memcpy'd */
- free(tran->install_pkgs->pkgs[i]);
+ free_pkg(tran->install_pkgs->pkgs[i]);
}
free(tran->install_pkgs->pkgs);
free(tran->install_pkgs);
for(i = 0;i < tran->remove_pkgs->pkg_count; i++){
- /* no free_pkg() b/c the *pkg is all memcpy'd */
- free(tran->remove_pkgs->pkgs[i]);
+ free_pkg(tran->remove_pkgs->pkgs[i]);
}
free(tran->remove_pkgs->pkgs);
free(tran->remove_pkgs);
@@ -510,8 +502,7 @@ void free_transaction(transaction_t *tran){
free(tran->upgrade_pkgs);
for(i = 0; i < tran->exclude_pkgs->pkg_count;i++){
- /* no free_pkg() b/c the *pkg is all memcpy'd */
- free(tran->exclude_pkgs->pkgs[i]);
+ free_pkg(tran->exclude_pkgs->pkgs[i]);
}
free(tran->exclude_pkgs->pkgs);
free(tran->exclude_pkgs);