Root/slicer/util.h

1/*
2 * util.h - Common utility functions
3 *
4 * Written 2006, 2009, 2010 by Werner Almesberger
5 * Copyright 2006, 2009, 2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#ifndef UTIL_H
15#define UTIL_H
16
17#include <stdarg.h>
18#include <stdlib.h>
19#include <string.h>
20
21
22#define alloc_size(s) \
23    ({ void *alloc_size_tmp = malloc(s); \
24    if (!alloc_size_tmp) \
25        abort(); \
26    alloc_size_tmp; })
27
28#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
29
30#endif /* !UTIL_H */
31

Archive Download this file

Branches:
master



interactive