31,6 → 31,7 |
*/ |
|
/** @file |
* Integer to generic type map. |
*/ |
|
#ifndef __NET_INT_MAP_H__ |
41,9 → 42,18 |
#include <mem.h> |
#include <unistd.h> |
|
/** Internal magic value for a map consistency check. |
*/ |
#define INT_MAP_MAGIC_VALUE 0x11223344 |
|
/** Internal magic value for an item consistency check. |
*/ |
#define INT_MAP_ITEM_MAGIC_VALUE 0x55667788 |
|
/** Integer to generic type map declaration. |
* @param name Name of the map. Input parameter. |
* @param type Inner object type. Input parameter |
*/ |
#define INT_MAP_DECLARE( name, type ) \ |
\ |
typedef struct name name##_t; \ |
77,6 → 87,11 |
void name##_item_destroy( name##_item_ref item ); \ |
int name##_item_is_valid( name##_item_ref item ); |
|
/** Integer to generic type map implementation. |
* Should follow declaration with the same parameters. |
* @param name Name of the map. Input parameter. |
* @param type Inner object type. Input parameter |
*/ |
#define INT_MAP_IMPLEMENT( name, type ) \ |
\ |
int name##_add( name##_ref map, int key, type * value ){ \ |