Root/qpkg/util.h

Source at commit a9f12d56661a8e6def5a2b32519c3efd55e38d31 created 8 years 11 months ago.
By Werner Almesberger, qpkg: converted ID comparison from "struct id *" to "void *"
1/*
2 * util.h - Common utility functions
3 *
4 * Written 2009 by Werner Almesberger
5 * Copyright 2009 by 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#ifndef UTIL_H
14#define UTIL_H
15
16#include <stdlib.h>
17
18
19#define alloc_size(s) \
20    ({ void *alloc_size_tmp = malloc(s); \
21    if (!alloc_size_tmp) \
22        abort(); \
23    alloc_size_tmp; })
24
25#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
26
27#endif /* !UTIL_H */
28

Archive Download this file

Branches:
master



interactive