summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2002-09-09 08:00:32 +0000
committersobomax <sobomax@FreeBSD.org>2002-09-09 08:00:32 +0000
commitb02bdba74968a2671650f7212d6c98fc17f91596 (patch)
tree581c018d17748d977b8c193a9abfc7e28182d3f9 /usr.sbin/pkg_install
parent7ca7dd3e039714d993a2a5c696002e55c03a7271 (diff)
downloadFreeBSD-src-b02bdba74968a2671650f7212d6c98fc17f91596.zip
FreeBSD-src-b02bdba74968a2671650f7212d6c98fc17f91596.tar.gz
Vastly decrease amount of memory comsumed in the case when we have to read
ports/INDEX, by allocating eactly amount of memory necessary for storing each particular entry, insdead of 4K per entry (more than 7000 entries - go figure). Memory consumption went down to some 500K from some 30M.
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/version/perform.c11
-rw-r--r--usr.sbin/pkg_install/version/version.h4
2 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c
index efc4dff..fa71dfb 100644
--- a/usr.sbin/pkg_install/version/perform.c
+++ b/usr.sbin/pkg_install/version/perform.c
@@ -68,6 +68,8 @@ pkg_perform(char **indexarg)
i = -1;
while (pkgs[++i] != NULL) {
if (MatchName == NULL || strstr(pkgs[i], MatchName))
+ if (strcmp(pkgs[i], "mpeg_lib-1.3.1") == 0)
+ printf("Found!\n");
err_cnt += pkg_do(pkgs[i]);
}
@@ -75,6 +77,10 @@ pkg_perform(char **indexarg)
while (!SLIST_EMPTY(&Index)) {
ie = SLIST_FIRST(&Index);
SLIST_REMOVE_HEAD(&Index, next);
+ if (ie->name != NULL)
+ free(ie->name);
+ if (ie->origin != NULL)
+ free(ie->origin);
free(ie);
}
if (IndexFile != NULL)
@@ -157,8 +163,9 @@ pkg_do(char *pkg)
errx(2, "The INDEX does not appear to be valid!");
if ((ie = malloc(sizeof(struct index_entry))) == NULL)
errx(2, "Unable to allocate memory in %s.", __func__);
- strlcpy(ie->name, tmp, PATH_MAX);
- strlcpy(ie->origin, &ch[1], PATH_MAX);
+ bzero(ie, sizeof(struct index_entry));
+ ie->name = strdup(tmp);
+ ie->origin = strdup(&ch[1]);
/* Who really cares if we reverse the index... */
SLIST_INSERT_HEAD(&Index, ie, next);
}
diff --git a/usr.sbin/pkg_install/version/version.h b/usr.sbin/pkg_install/version/version.h
index 6ed6511..daaebb0 100644
--- a/usr.sbin/pkg_install/version/version.h
+++ b/usr.sbin/pkg_install/version/version.h
@@ -32,8 +32,8 @@
struct index_entry {
SLIST_ENTRY(index_entry) next;
- char name[PATH_MAX];
- char origin[PATH_MAX];
+ char *name;
+ char *origin;
};
SLIST_HEAD(index_head, index_entry);
OpenPOWER on IntegriCloud