Root/poly2d/util.h

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

Archive Download this file

Branches:
master



interactive