mirror of
https://github.com/hmaxnl/netex.git
synced 2025-01-18 23:44:20 +01:00
Compare commits
No commits in common. "7e15e12d459b71d97911ba3c886ac805e0defe0f" and "4c9c547e62f4b204f737a30dae984842fa44e0e2" have entirely different histories.
7e15e12d45
...
4c9c547e62
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
list_node * insert_node(list_node* list, void* data)
|
list_node * insert_end(list_node* list, void* data)
|
||||||
{
|
{
|
||||||
list_node* node = (list_node*)malloc(sizeof(list_node));
|
list_node* node = (list_node*)malloc(sizeof(list_node));
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
|
@ -41,9 +41,7 @@ void delete_node(list_node* node)
|
||||||
{
|
{
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return;
|
return;
|
||||||
if (node->previous != NULL)
|
|
||||||
node->previous->next = node->next;
|
node->previous->next = node->next;
|
||||||
if (node->next != NULL)
|
|
||||||
node->next->previous = node->previous;
|
node->next->previous = node->previous;
|
||||||
free(node);
|
free(node);
|
||||||
}
|
}
|
||||||
|
@ -55,36 +53,11 @@ void iterate_list(list_node* list, bool forward, int (*iterFunc)(const void*))
|
||||||
list_node * current = list;
|
list_node * current = list;
|
||||||
while (current != NULL)
|
while (current != NULL)
|
||||||
{
|
{
|
||||||
list_node* temp_next = current->next;
|
if (iterFunc(current->data) == 1)
|
||||||
list_node* temp_previous = current->previous;
|
|
||||||
|
|
||||||
// State
|
|
||||||
int iter_state = iterFunc(current->data);
|
|
||||||
if (iter_state & DELETE)
|
|
||||||
delete_node(current);
|
|
||||||
if (iter_state & BREAK)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (forward)
|
|
||||||
current = temp_next;
|
|
||||||
else
|
|
||||||
current = temp_previous;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list_node* find_node(list_node* list_start, bool forward, int (*findFunc)(const void*))
|
|
||||||
{
|
|
||||||
if (list_start == NULL || findFunc == NULL)
|
|
||||||
return NULL;
|
|
||||||
list_node* current = list_start;
|
|
||||||
while (current != NULL)
|
|
||||||
{
|
|
||||||
if (findFunc(current->data) == 1)
|
|
||||||
return current;
|
|
||||||
if (forward)
|
if (forward)
|
||||||
current = current->next;
|
current = current->next;
|
||||||
else
|
else
|
||||||
current = current->previous;
|
current = current->previous;
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
}
|
}
|
|
@ -2,13 +2,6 @@
|
||||||
#define NETEX_LIST_H
|
#define NETEX_LIST_H
|
||||||
|
|
||||||
|
|
||||||
typedef enum list_iterate_states
|
|
||||||
{
|
|
||||||
CONTINUE = 0 << 0,
|
|
||||||
BREAK = 1 << 0,
|
|
||||||
DELETE = 1 << 1
|
|
||||||
}iterate_state;
|
|
||||||
|
|
||||||
typedef struct list_node
|
typedef struct list_node
|
||||||
{
|
{
|
||||||
void* data;
|
void* data;
|
||||||
|
@ -16,7 +9,6 @@ typedef struct list_node
|
||||||
struct list_node* next;
|
struct list_node* next;
|
||||||
} list_node;
|
} list_node;
|
||||||
|
|
||||||
void delete_node(list_node* node);
|
|
||||||
void iterate_list(list_node* list, bool forward, int (*iterFunc)(const void*));
|
void iterate_list(list_node* list, bool forward, int (*iterFunc)(const void*));
|
||||||
|
|
||||||
#endif //NETEX_LIST_H
|
#endif //NETEX_LIST_H
|
||||||
|
|
|
@ -18,15 +18,16 @@ int shutdown_logger(const void* data)
|
||||||
logger->app_logger = NULL;
|
logger->app_logger = NULL;
|
||||||
logger->name = NULL;
|
logger->name = NULL;
|
||||||
free(logger);
|
free(logger);
|
||||||
return DELETE | BREAK;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown_log(app_logger_info* appLogger)
|
void shutdown_log(app_logger_info* appLogger)
|
||||||
{
|
{
|
||||||
canLog = false;
|
canLog = false;
|
||||||
iterate_list(appLogger->loggers, true, &shutdown_logger);
|
iterate_list(appLogger->loggers, true, &shutdown_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger* create_logger(app_logger_info* appLogger, char* name)
|
logger* create_logger(app_logger_info* appLogger, char* name)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user