summaryrefslogtreecommitdiff
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2002-11-27 00:37:54 +0000
committerMarc Espie <espie@cvs.openbsd.org>2002-11-27 00:37:54 +0000
commit5ca28975edd9ade46ca51e642be681475f64fa5b (patch)
tree58599c35c276cfce1246d27250346e66ca325174 /gnu/usr.bin
parentf7afd0185038c03ec356d872aeefd4ad60dd6ea5 (diff)
Kill some alloca. Reduces temp allocation for big static libraries drastically,
allow, e.g., linking against static debug qt (or debug static mozilla for that matter). okay miod@
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/ld/lib.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gnu/usr.bin/ld/lib.c b/gnu/usr.bin/ld/lib.c
index 759f8e26d44..ad0d5762630 100644
--- a/gnu/usr.bin/ld/lib.c
+++ b/gnu/usr.bin/ld/lib.c
@@ -1,4 +1,4 @@
-/* * $OpenBSD: lib.c,v 1.10 2002/09/07 01:25:34 marc Exp $ - library routines*/
+/* * $OpenBSD: lib.c,v 1.11 2002/11/27 00:37:53 espie Exp $ - library routines*/
/*
*/
@@ -289,7 +289,7 @@ symdef_library(int fd, struct file_entry *entry, int member_length)
read_entry_symbols(fd, subentry);
subentry->strings = (char *)
- alloca(subentry->string_size);
+ xmalloc(subentry->string_size);
read_entry_strings(fd, subentry);
/*
@@ -299,8 +299,8 @@ symdef_library(int fd, struct file_entry *entry, int member_length)
if (!(link_mode & FORCEARCHIVE) &&
!subfile_wanted_p(subentry)) {
- if (subentry->symbols)
- free(subentry->symbols);
+ free(subentry->symbols);
+ free(subentry->strings);
free(subentry);
} else {
/*
@@ -336,6 +336,7 @@ symdef_library(int fd, struct file_entry *entry, int member_length)
* We'll read the strings again
* if we need them.
*/
+ free(subentry->strings);
subentry->strings = 0;
}
}
@@ -368,13 +369,13 @@ linear_library(int fd, struct file_entry *entry)
return;
read_entry_symbols(fd, subentry);
- subentry->strings = (char *)alloca(subentry->string_size);
+ subentry->strings = (char *)xmalloc(subentry->string_size);
read_entry_strings(fd, subentry);
if (!(link_mode & FORCEARCHIVE) &&
!subfile_wanted_p(subentry)) {
- if (subentry->symbols)
- free(subentry->symbols);
+ free(subentry->symbols);
+ free(subentry->strings);
free(subentry);
} else {
read_entry_relocation(fd, subentry);
@@ -385,8 +386,8 @@ linear_library(int fd, struct file_entry *entry)
else
entry->subfiles = subentry;
prev = subentry;
- subentry->strings = 0; /* Since space will dissapear
- * on return */
+ free(subentry->strings);
+ subentry->strings = 0;
}
this_subfile_offset += member_length + sizeof(struct ar_hdr);