FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
uwac-utils.c
1/*
2 * Copyright © 2012 Collabora, Ltd.
3 * Copyright © 2008 Kristian Høgsberg
4 * Copyright © 2014 David FORT <contact@hardening-consulting.com>
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting documentation, and
10 * that the name of the copyright holders not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. The copyright holders make no representations
13 * about the suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty.
15 *
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
23 */
24
25#include <uwac/config.h>
26
27#include <stdlib.h>
28#include <stdio.h>
29#include <string.h>
30#include <errno.h>
31
32#include "uwac-utils.h"
33
34/*
35 * This part is an adaptation of client/window.c from the weston project.
36 */
37
38static void* fail_on_null(void* p)
39{
40 if (p == NULL)
41 {
42 (void)fprintf(stderr, "out of memory\n");
43 // NOLINTNEXTLINE(concurrency-mt-unsafe)
44 exit(EXIT_FAILURE);
45 }
46
47 return p;
48}
49
50void* xmalloc(size_t s)
51{
52 return fail_on_null(malloc(s));
53}
54
55void* xzalloc(size_t s)
56{
57 return fail_on_null(zalloc(s));
58}
59
60char* xstrdup(const char* s)
61{
62 return fail_on_null(strdup(s));
63}
64
65void* xrealloc(void* p, size_t s)
66{
67 return fail_on_null(realloc(p, s));
68}