Multiple changes

- updated documentation
- corrected data type for two list_append calls
This commit is contained in:
Walter Julius Hennecke 2013-04-09 22:40:50 +02:00
parent f2e72ef75f
commit cc5b7d27ce
3 changed files with 46 additions and 16 deletions

View file

@ -7458,7 +7458,7 @@ void addShaderToList(list_p list, char *shader) {
}
}
list_append(list, s, LT_DATA, strlen(s)+1);
list_append(list, s, LT_STRING, strlen(s)+1);
}
extern target_alert_Shaders_s alertShaders;

View file

@ -960,7 +960,7 @@ static void G_LoadTimedMessages(void) {
continue;
}
list_append(level.timedMessages, token, LT_DATA, strlen(token)+1);
list_append(level.timedMessages, token, LT_STRING, strlen(token)+1);
} else {
if(token[0] == '}') {
break;

View file

@ -30,6 +30,10 @@ Can be used as a LIFO stack of FIFO queue. */
#define LIST_FRONT 0
#define LIST_BACK 1
/**
* Possible type the data in a container may have.
* LT_DATA means that a custom struct was added.
*/
typedef enum {
LT_BOOLEAN,
LT_CHAR,
@ -46,38 +50,64 @@ typedef enum {
LT_MAX
} dataType_t;
/**
* Container for data added to the list.
* Use of a container allows to add standard c types to the list
* without the need to embed them into a struct.
*/
struct container {
void* data;
size_t size;
dataType_t type;
int pointer;
void* data; /*!< pointer to the data */
size_t size; /*!< size of the data */
dataType_t type; /*!< type of the data */
char pointer; /*!< determin if the data is a pointer */
} container;
/**
* Type for a pointer to a container.
*/
typedef struct container* container_p;
/**
* Node for a double linked list.
*/
struct linked_node {
container_p cont;
struct linked_node* next;
struct linked_node* prev;
container_p cont; /*!< cointainer with the data */
struct linked_node* next; /*!< next list element */
struct linked_node* prev; /*!< previous list element */
};
/**
* Type for a pointer to a node.
*/
typedef struct linked_node* lnode_p;
/**
* Struct describing a list.
*/
struct list{
int length;
lnode_p first;
lnode_p last;
void (*destructor)(void*);
int length; /*!< count of elements in the list */
lnode_p first; /*!< first element of the list */
lnode_p last; /*!< last element of the list */
void (*destructor)(void*); /*!< pointer to destructor for data. Default is free. */
};
/**
* Type for a pointer to a list.
*/
typedef struct list * list_p;
/**
* Struct describing a list iterator.
*/
struct list_iter{
list_p list;
lnode_p current;
char started;
list_p list; /*!< the list */
lnode_p current; /*!< current node */
char started; /*!< has iteration started */
};
/**
* Type for a pointer to a list iterator.
*/
typedef struct list_iter * list_iter_p;
/**