chiark / gitweb /
fishdescriptor: Fix a typo
[chiark-utils.git] / cprogs / common.c
1 /*
2  * common.[ch] - C helpers common to the whole of chiark-utils
3  *
4  * Copyright 2007 Canonical Ltd
5  * Copyright 2016 Canonical Ltd
6  *
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this file; if not, consult the Free Software
20  * Foundation's website at www.fsf.org, or the GNU Project website at
21  * www.gnu.org.
22  *
23  */
24
25 #include "common.h"
26
27 char *m_vasprintf(const char *fmt, va_list al) {
28   char *s;  int r;
29   r= vasprintf(&s,fmt,al);
30   if (r==-1) common_diee("vasprintf");
31   return s;
32 }
33 char *m_asprintf(const char *fmt, ...) {
34   char *s;  va_list al;
35   va_start(al,fmt); s= m_vasprintf(fmt,al); va_end(al);
36   return s;
37 }
38
39 void *xmalloc(size_t sz) {
40   void *r= malloc(sz);
41   if (!r) common_diee("malloc");
42   return r;
43 }