aboutsummaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authorokan2012-11-28 14:32:44 +0000
committerokan2012-11-28 14:32:44 +0000
commiteb6770c71a17ba371b3f345a7e1cd1e31c021190 (patch)
tree649769916d8c99bd19da044786e0db3c5bdd68ca /xmalloc.c
parent3e838c50e74c439ba1e2312238d5414be89031f7 (diff)
downloadcwm-eb6770c71a17ba371b3f345a7e1cd1e31c021190.tar.gz
add xasprintf() for upcoming changes.
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 8e9d22a..c278e72 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: xmalloc.c,v 1.10 2012/11/16 14:15:48 okan Exp $
+ * $OpenBSD: xmalloc.c,v 1.11 2012/11/28 14:32:44 okan Exp $
*/
#include <sys/param.h>
@@ -69,3 +69,19 @@ xstrdup(const char *str)
return (p);
}
+
+int
+xasprintf(char **ret, const char *fmt, ...)
+{
+ va_list ap;
+ int i;
+
+ va_start(ap, fmt);
+ i = vasprintf(ret, fmt, ap);
+ va_end(ap);
+
+ if (i < 0 || *ret == NULL)
+ err(1, "asprintf");
+
+ return (i);
+}