2010-10-27 19:51:49 +02:00
|
|
|
/*
|
2011-03-05 13:44:21 +01:00
|
|
|
* This software is licensed under the terms of the MIT-License
|
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
|
|
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
2010-10-27 19:51:49 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIST_H
|
|
|
|
#define LIST_H
|
|
|
|
|
|
|
|
/* I got annoyed of the code doubling caused by simple linked lists,
|
|
|
|
* so i do some void-magic here to save the lines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void *create_element(void **dest, int size);
|
2011-04-26 22:39:50 +02:00
|
|
|
void delete_element(void **dest, void *e);
|
2011-05-08 13:48:25 +02:00
|
|
|
void delete_all_elements(void **dest, void (callback)(void **, void *));
|
2010-10-27 19:51:49 +02:00
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
typedef struct {
|
2011-07-07 14:34:30 +02:00
|
|
|
void *ptr;
|
|
|
|
int refs;
|
|
|
|
} Reference;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Reference *ptrs;
|
2011-05-13 19:03:02 +02:00
|
|
|
int count;
|
|
|
|
} RefArray;
|
|
|
|
|
|
|
|
extern void *_FREEREF;
|
|
|
|
#define FREEREF &_FREEREF
|
2011-07-07 14:34:30 +02:00
|
|
|
#define REF(p) (global.refs.ptrs[(int)(p)].ptr)
|
2011-05-13 19:03:02 +02:00
|
|
|
int add_ref(void *ptr);
|
|
|
|
void del_ref(void *ptr);
|
|
|
|
void free_ref(int i);
|
2010-10-27 19:51:49 +02:00
|
|
|
#endif
|