[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Remove deps on *printf(3) in libltdl
From: |
Ralf Wildenhues |
Subject: |
Remove deps on *printf(3) in libltdl |
Date: |
Tue, 21 Dec 2004 10:24:34 +0100 |
User-agent: |
Mutt/1.5.6+20040907i |
As announced some time ago, I'd like to get rid of *printf in libltdl.
This is primarily an advantage for small-sized software. With static
dietlibc on linux-x86, I can get an executable using libltdl at about
20K stripped size, which is not great, but a third less than without
this patch (this is including all libc functions, of course!).
Another side not is in place here, since I do not make use of strl*:
With allocated buffers of precomputed size, there can be no overflow
(unless you compute wrongly, of course). I do not see much value in
safeguarding what would otherwise be a bug anyway. YMMV.
OK to apply to HEAD?
Regards,
Ralf
* libltdl/lt__alloc.c (alloc_die_default),
libltdl/ltdl.c (tryall_dlopen_module, load_deplibs):
Replace all *printf invocations.
Index: libltdl/lt__alloc.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/lt__alloc.c,v
retrieving revision 1.4
diff -u -r1.4 lt__alloc.c
--- libltdl/lt__alloc.c 1 Oct 2004 10:24:18 -0000 1.4
+++ libltdl/lt__alloc.c 21 Dec 2004 07:07:42 -0000
@@ -44,7 +44,7 @@
static void
alloc_die_default (void)
{
- fprintf (stderr, "Out of memory.\n");
+ fputs ("Out of memory.\n", stderr);
exit (EXIT_FAILURE);
}
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.228
diff -u -r1.228 ltdl.c
--- libltdl/ltdl.c 16 Dec 2004 12:00:09 -0000 1.228
+++ libltdl/ltdl.c 21 Dec 2004 07:07:43 -0000
@@ -422,7 +422,9 @@
if (!filename)
return 1;
- sprintf (filename, "%.*s/%s", (int) dirname_len, dirname, dlname);
+ strcpy (filename, dirname);
+ filename[dirname_len] = '/';
+ strcpy (filename + dirname_len + 1, dlname);
/* Now that we have combined DIRNAME and MODULENAME, if there is
also a PREFIX to contend with, simply recurse with the arguments
@@ -814,7 +816,10 @@
size_t name_len = 3+ /* "lib" */ LT_STRLEN (p + 2);
name = MALLOC (char, 1+ name_len);
if (name)
- sprintf (name, "lib%s", p+2);
+ {
+ strcpy(name, "lib");
+ strcpy(name + 3, p+2);
+ }
}
else
name = lt__strdup(p);
- Remove deps on *printf(3) in libltdl,
Ralf Wildenhues <=