fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
set.h
Go to the documentation of this file.
1
#ifndef FSAUTOPROC_SET_H
2
#define FSAUTOPROC_SET_H
3
4
#define DEFINE_SET(name, typ) \
5
struct name##_s { \
6
int count; \
7
typ* items; \
8
}; \
9
typedef struct name##_s name##_t;
10
11
#define DECLARE_STATIC_SET_FREE(name, typ) \
12
static void name##_free(name##_t* set) { \
13
if (set != NULL) { \
14
je_free(set->items); \
15
set->items = NULL; \
16
set->count = 0; \
17
je_free(set); \
18
} \
19
}
20
21
#define DECLARE_STATIC_SET_ALLOC(name, typ) \
22
static name##_t* name##_alloc(int count) { \
23
void* items = je_calloc(count, sizeof(typ)); \
24
if (!items) return NULL; \
25
name##_t* set = je_malloc(sizeof(name##_t)); \
26
if (!set) { \
27
je_free(items); \
28
return NULL; \
29
} \
30
set->count = count; \
31
set->items = (typ*) items; \
32
return set; \
33
}
34
35
#define SET_AT(name, index) \
36
(name != NULL && name->items != NULL && index >= 0 && index < name->count \
37
? &(name)->items[index] \
38
: NULL)
39
40
#endif
//FSAUTOPROC_SET_H
include
set.h
Generated by
1.9.8