diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/db.c | 18 | ||||
-rw-r--r-- | src/common/db.h | 13 |
2 files changed, 19 insertions, 12 deletions
diff --git a/src/common/db.c b/src/common/db.c index bd2bea424..b3a58e0a4 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -2730,20 +2730,26 @@ void linkdb_insert( struct linkdb_node** head, void *key, void* data) node->data = data; } -void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... ) -{ +void linkdb_vforeach( struct linkdb_node** head, LinkDBFunc func, va_list ap) { struct linkdb_node *node; if( head == NULL ) return; node = *head; while ( node ) { - va_list args; - va_start(args, func); - func( node->key, node->data, args ); - va_end(args); + va_list argscopy; + va_copy(argscopy, ap); + func(node->key, node->data, argscopy); + va_end(argscopy); node = node->next; } } +void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ...) { + va_list ap; + va_start(ap, func); + linkdb_vforeach(head, func, ap); + va_end(ap); +} + void* linkdb_search( struct linkdb_node** head, void *key) { int n = 0; diff --git a/src/common/db.h b/src/common/db.h index aa4bfb054..dffd2356d 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -882,12 +882,13 @@ struct linkdb_node { typedef void (*LinkDBFunc)(void* key, void* data, va_list args); -void linkdb_insert ( struct linkdb_node** head, void *key, void* data); // 重複を考慮しない -void linkdb_replace( struct linkdb_node** head, void *key, void* data); // 重複を考慮する -void* linkdb_search ( struct linkdb_node** head, void *key); -void* linkdb_erase ( struct linkdb_node** head, void *key); -void linkdb_final ( struct linkdb_node** head ); -void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... ); +void linkdb_insert (struct linkdb_node** head, void *key, void* data); // 重複を考慮しない +void linkdb_replace (struct linkdb_node** head, void *key, void* data); // 重複を考慮する +void* linkdb_search (struct linkdb_node** head, void *key); +void* linkdb_erase (struct linkdb_node** head, void *key); +void linkdb_final (struct linkdb_node** head); +void linkdb_vforeach(struct linkdb_node** head, LinkDBFunc func, va_list ap); +void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); |