fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
set.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEFINE_SET(name, typ)
 
#define DECLARE_STATIC_SET_FREE(name, typ)
 
#define DECLARE_STATIC_SET_ALLOC(name, typ)
 
#define SET_AT(name, index)
 

Macro Definition Documentation

◆ DECLARE_STATIC_SET_ALLOC

#define DECLARE_STATIC_SET_ALLOC (   name,
  typ 
)
Value:
static name##_t* name##_alloc(int count) { \
void* items = je_calloc(count, sizeof(typ)); \
if (!items) return NULL; \
name##_t* set = je_malloc(sizeof(name##_t)); \
if (!set) { \
je_free(items); \
return NULL; \
} \
set->count = count; \
set->items = (typ*) items; \
return set; \
}

◆ DECLARE_STATIC_SET_FREE

#define DECLARE_STATIC_SET_FREE (   name,
  typ 
)
Value:
static void name##_free(name##_t* set) { \
if (set != NULL) { \
je_free(set->items); \
set->items = NULL; \
set->count = 0; \
je_free(set); \
} \
}

◆ DEFINE_SET

#define DEFINE_SET (   name,
  typ 
)
Value:
struct name##_s { \
int count; \
typ* items; \
}; \
typedef struct name##_s name##_t;

◆ SET_AT

#define SET_AT (   name,
  index 
)
Value:
(name != NULL && name->items != NULL && index >= 0 && index < name->count \
? &(name)->items[index] \
: NULL)