mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-12-24 01:36:27 +02:00
48434c859d
The "gencat" with older rights to the name is from libc, no less. I wonder how I missed that :-(
40 lines
742 B
C
40 lines
742 B
C
/*
|
|
* util.h - Utility functions
|
|
*
|
|
* Copyright 2012 by Werner Almesberger
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
#ifndef UTIL_H
|
|
#define UTIL_H
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
|
|
#define alloc_size(s) \
|
|
({ void *alloc_size_tmp = malloc(s); \
|
|
if (!alloc_size_tmp) \
|
|
abort(); \
|
|
alloc_size_tmp; })
|
|
|
|
#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
|
|
|
|
|
|
static inline char *stralloc(const char *s)
|
|
{
|
|
char *t;
|
|
|
|
t = strdup(s);
|
|
if (t)
|
|
return t;
|
|
perror("strdup");
|
|
exit(1);
|
|
}
|
|
|
|
#endif /* !UTIL_H */
|