The following commit has been merged in the master branch:
commit abcde2189e74065b2807b3984031ef33fe64742b
Author: Guillem Jover <[email protected]>
Date: Sun Nov 7 09:05:36 2010 +0100
u-a: Create new xvasprintf() and use it instead of ad-hoc code
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index f14979f..7e9d817 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -285,6 +285,18 @@ xreadlink(const char *linkname, bool error_out)
return buf;
}
+static int DPKG_ATTR_VPRINTF(2)
+xvasprintf(char **strp, const char *fmt, va_list args)
+{
+ int ret;
+
+ ret = vasprintf(strp, fmt, args);
+ if (ret < 0)
+ error(_("failed to allocate memory"));
+
+ return ret;
+}
+
static int DPKG_ATTR_PRINTF(2)
xasprintf(char **strp, const char *fmt, ...)
{
@@ -292,10 +304,8 @@ xasprintf(char **strp, const char *fmt, ...)
int ret;
va_start(args, fmt);
- ret = vasprintf(strp, fmt, args);
+ ret = xvasprintf(strp, fmt, args);
va_end(args);
- if (ret < 0)
- error(_("failed to allocate memory"));
return ret;
}
@@ -1028,10 +1038,8 @@ altdb_parse_error(struct altdb_context *ctx, const char
*format, ...)
int ret;
va_start(args, format);
- ret = vasprintf(&msg, format, args);
+ ret = xvasprintf(&msg, format, args);
va_end(args);
- if (ret < 0)
- error(_("failed to allocate memory"));
error(_("%s corrupt: %s"), ctx->filename, msg);
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]