mirror of
https://github.com/hmaxnl/netex.git
synced 2025-01-18 15:34:20 +01:00
[CHANGE] 'iterate_list' function handles by flags
This commit is contained in:
parent
9c8cdcd94d
commit
7e15e12d45
|
@ -55,12 +55,20 @@ 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)
|
||||||
{
|
{
|
||||||
if (iterFunc(current->data) == 1)
|
list_node* temp_next = current->next;
|
||||||
|
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)
|
if (forward)
|
||||||
current = current->next;
|
current = temp_next;
|
||||||
else
|
else
|
||||||
current = current->previous;
|
current = temp_previous;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
#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;
|
||||||
|
@ -9,6 +16,7 @@ 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,7 +18,7 @@ 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 0;
|
return DELETE | BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown_log(app_logger_info* appLogger)
|
void shutdown_log(app_logger_info* appLogger)
|
||||||
|
@ -27,8 +27,6 @@ void shutdown_log(app_logger_info* appLogger)
|
||||||
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