Root/fakefile/util.h

Source at commit 51106cf9b34d773e72aa00385c80a9abb76b28df created 5 years 11 months ago.
By Werner Almesberger, ircstat/ML: update for 11/2013
1/*
2 * util.h - Utility functions
3 *
4 * Copyright 2012 by Werner Almesberger
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef UTIL_H
13#define UTIL_H
14
15#include <stdlib.h>
16
17
18#define alloc_size(s) \
19    ({ void *alloc_size_tmp = malloc(s); \
20    if (!alloc_size_tmp) \
21        abort(); \
22    alloc_size_tmp; })
23
24#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
25
26#endif /* !UTIL_H */
27

Archive Download this file

Branches:
master



interactive