diff options
author | Guillem Jover <guillem@debian.org> | 2011-01-12 01:24:58 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2011-01-16 10:19:21 +0100 |
commit | f4b0dd0456af74edea2f117423e4b2a9959e8e59 (patch) | |
tree | 7abbbeb8dd4d57963962b9aaa90aae1458c91a87 /dpkg-split | |
parent | 881d62b236b52c35a367c49c3737c2b4dfdb7ede (diff) | |
download | dpkg-f4b0dd0456af74edea2f117423e4b2a9959e8e59.tar.gz |
Use m_asprintf() instead varbuf_printf() for one-off strings
When the string is only created once, used several times and then
freed, there's no much point in using a varbuf instead of the simpler
m_asprintf(). The former needs more state and makes using the string
slightly more cumbersome. Using m_asprintf() should be slightly faster
too, but not significantly enough to justify this change by itself.
Diffstat (limited to 'dpkg-split')
-rw-r--r-- | dpkg-split/split.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/dpkg-split/split.c b/dpkg-split/split.c index 5c8f4f2c3..311ffc62e 100644 --- a/dpkg-split/split.c +++ b/dpkg-split/split.c @@ -171,15 +171,14 @@ mksplit(const char *file_src, const char *prefix, size_t maxpartsize, varbuf_reset(&file_dst); /* Generate output filename. */ if (msdos) { - struct varbuf refname = VARBUF_INIT; + char *refname; int prefix_max; - varbuf_printf(&refname, "%dof%d", curpart, nparts); - prefix_max = max(8 - strlen(refname.buf), 0); + m_asprintf(&refname, "%dof%d", curpart, nparts); + prefix_max = max(8 - strlen(refname), 0); varbuf_printf(&file_dst, "%s/%.*s%.8s.deb", - prefixdir, prefix_max, prefix, - refname.buf); - varbuf_destroy(&refname); + prefixdir, prefix_max, prefix, refname); + free(refname); } else { varbuf_printf(&file_dst, "%s.%dof%d.deb", prefix, curpart, nparts); |