2 * common.[ch] - C helpers common to the whole of chiark-utils
4 * Copyright 2007 Canonical Ltd
5 * Copyright 2016 Canonical Ltd
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.
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.
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
27 char *m_vasprintf(const char *fmt, va_list al) {
29 r= vasprintf(&s,fmt,al);
30 if (r==-1) common_diee("vasprintf");
33 char *m_asprintf(const char *fmt, ...) {
35 va_start(al,fmt); s= m_vasprintf(fmt,al); va_end(al);
39 void *xmalloc(size_t sz) {
41 if (!r) common_diee("malloc");