Blame uwac/libuwac/uwac-utils.c

Packit 1fb8d4
/*
Packit 1fb8d4
 * Copyright © 2012 Collabora, Ltd.
Packit 1fb8d4
 * Copyright © 2008 Kristian Høgsberg
Packit 1fb8d4
 * Copyright © 2014 David FORT <contact@hardening-consulting.com>
Packit 1fb8d4
 *
Packit 1fb8d4
 * Permission to use, copy, modify, distribute, and sell this software and its
Packit 1fb8d4
 * documentation for any purpose is hereby granted without fee, provided that
Packit 1fb8d4
 * the above copyright notice appear in all copies and that both that copyright
Packit 1fb8d4
 * notice and this permission notice appear in supporting documentation, and
Packit 1fb8d4
 * that the name of the copyright holders not be used in advertising or
Packit 1fb8d4
 * publicity pertaining to distribution of the software without specific,
Packit 1fb8d4
 * written prior permission.  The copyright holders make no representations
Packit 1fb8d4
 * about the suitability of this software for any purpose.  It is provided "as
Packit 1fb8d4
 * is" without express or implied warranty.
Packit 1fb8d4
 *
Packit 1fb8d4
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
Packit 1fb8d4
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
Packit 1fb8d4
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
Packit 1fb8d4
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
Packit 1fb8d4
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
Packit 1fb8d4
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
Packit 1fb8d4
 * OF THIS SOFTWARE.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#include "config.h"
Packit 1fb8d4
Packit 1fb8d4
#include <stdlib.h>
Packit 1fb8d4
#include <stdio.h>
Packit 1fb8d4
#include <string.h>
Packit 1fb8d4
#include <errno.h>
Packit 1fb8d4
Packit 1fb8d4
#include "uwac-utils.h"
Packit 1fb8d4
Packit 1fb8d4
/*
Packit 1fb8d4
 * This part is an adaptation of client/window.c from the weston project.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit Service 5a9772
static void* fail_on_null(void* p)
Packit Service 5a9772
{
Packit Service 5a9772
	if (p == NULL)
Packit Service 5a9772
	{
Packit 1fb8d4
		fprintf(stderr, "out of memory\n");
Packit 1fb8d4
		exit(EXIT_FAILURE);
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return p;
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
void* xmalloc(size_t s)
Packit Service 5a9772
{
Packit 1fb8d4
	return fail_on_null(malloc(s));
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
void* xzalloc(size_t s)
Packit Service 5a9772
{
Packit 1fb8d4
	return fail_on_null(zalloc(s));
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
char* xstrdup(const char* s)
Packit Service 5a9772
{
Packit 1fb8d4
	return fail_on_null(strdup(s));
Packit 1fb8d4
}
Packit 1fb8d4
Packit Service 5a9772
void* xrealloc(void* p, size_t s)
Packit Service 5a9772
{
Packit 1fb8d4
	return fail_on_null(realloc(p, s));
Packit 1fb8d4
}