-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static void oom(void) AVAHI_GCC_NORETURN;
static void oom(void) {
-
+
static const char msg[] = "Out of memory, aborting ...\n";
const char *n = msg;
while (strlen(n) > 0) {
ssize_t r;
-
+
if ((r = write(2, n, strlen(n))) < 0)
break;
/* Default implementation for avahi_calloc() */
static void *xcalloc(size_t nmemb, size_t size) {
void *p;
-
+
if (size == 0 || nmemb == 0)
return NULL;
if (size <= 0)
return NULL;
-
+
if (!allocator)
return xmalloc(size);
if (!p)
return;
-
+
if (!allocator) {
free(p);
return;
char *avahi_strdup(const char *s) {
char *r;
size_t size;
-
+
if (!s)
return NULL;
char *r;
size_t size;
const char *p;
-
+
if (!s)
return NULL;
for (p = s, size = 0;
size < max && *p;
p++, size++);
-
+
if (!(r = avahi_new(char, size+1)))
return NULL;
char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
size_t len = 80;
char *buf;
-
+
assert(fmt);
if (!(buf = avahi_malloc(len)))
va_list ap;
assert(fmt);
-
+
va_start(ap, fmt);
s = avahi_strdup_vprintf(fmt, ap);
va_end(ap);