Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-02-09 11:28:22 +0100
committerAllan McRae <allan@archlinux.org>2014-03-03 11:25:54 +1000
commitb6f6a165c4630cac86efb2608b9909b20488a710 (patch)
tree6b7cf35f75ce0026202ee5c3c03eb055ce40cb94 /lib/libalpm
parent5acfa65ffb4aab31e05b70cea164dcb3e011d91f (diff)
be_local: Use alpm_greedy_grow
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/be_local.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 0b5b266f..5474995e 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -736,22 +736,9 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
while(fgets(line, sizeof(line), fp) &&
(len = _alpm_strip_newline(line, 0))) {
- if(files_count >= files_size) {
- size_t old_size = files_size;
- if(files_size == 0) {
- files_size = 8;
- } else {
- files_size *= 2;
- }
- files = realloc(files, sizeof(alpm_file_t) * files_size);
- if(!files) {
- _alpm_alloc_fail(sizeof(alpm_file_t) * files_size);
- goto error;
- }
- /* ensure all new memory is zeroed out, in both the initial
- * allocation and later reallocs */
- memset(files + old_size, 0,
- sizeof(alpm_file_t) * (files_size - old_size));
+ if(!_alpm_greedy_grow((void **)&files, &files_size,
+ (files_size ? files_size + sizeof(alpm_file_t) : 8 * sizeof(alpm_file_t)))) {
+ goto error;
}
/* since we know the length of the file string already,
* we can do malloc + memcpy rather than strdup */