diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/db.c | 56 | ||||
-rw-r--r-- | src/common/db.h | 36 | ||||
-rw-r--r-- | src/common/socket.c | 2 |
3 files changed, 49 insertions, 45 deletions
diff --git a/src/common/db.c b/src/common/db.c index 639d42156..fa1a6d65c 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -234,17 +234,17 @@ typedef struct DBMap_impl { * @param ht_index Current index of the hashtable * @param node Current node * @private - * @see #DBIterator + * @see struct DBIterator * @see #DBMap_impl * @see #DBNode */ -typedef struct DBIterator_impl { +struct DBIterator_impl { // Iterator interface struct DBIterator vtable; DBMap_impl* db; int ht_index; DBNode *node; -} DBIterator_impl; +}; #if defined(DB_ENABLE_STATS) /** @@ -1245,11 +1245,11 @@ static void db_release_both(union DBKey key, struct DBData data, enum DBReleaseO * @param out_key Key of the entry * @return Data of the entry * @protected - * @see DBIterator#first + * @see struct DBIterator#first() */ -struct DBData *dbit_obj_first(DBIterator* self, union DBKey *out_key) +struct DBData *dbit_obj_first(struct DBIterator *self, union DBKey *out_key) { - DBIterator_impl* it = (DBIterator_impl*)self; + struct DBIterator_impl *it = (struct DBIterator_impl *)self; DB_COUNTSTAT(dbit_first); // position before the first entry @@ -1267,11 +1267,11 @@ struct DBData *dbit_obj_first(DBIterator* self, union DBKey *out_key) * @param out_key Key of the entry * @return Data of the entry * @protected - * @see DBIterator#last + * @see struct DBIterator#last() */ -struct DBData *dbit_obj_last(DBIterator* self, union DBKey *out_key) +struct DBData *dbit_obj_last(struct DBIterator *self, union DBKey *out_key) { - DBIterator_impl* it = (DBIterator_impl*)self; + struct DBIterator_impl *it = (struct DBIterator_impl *)self; DB_COUNTSTAT(dbit_last); // position after the last entry @@ -1289,11 +1289,11 @@ struct DBData *dbit_obj_last(DBIterator* self, union DBKey *out_key) * @param out_key Key of the entry * @return Data of the entry * @protected - * @see DBIterator#next + * @see struct DBIterator#next() */ -struct DBData *dbit_obj_next(DBIterator* self, union DBKey *out_key) +struct DBData *dbit_obj_next(struct DBIterator *self, union DBKey *out_key) { - DBIterator_impl* it = (DBIterator_impl*)self; + struct DBIterator_impl *it = (struct DBIterator_impl *)self; DBNode *node; DBNode *parent; struct dbn fake; @@ -1365,11 +1365,11 @@ struct DBData *dbit_obj_next(DBIterator* self, union DBKey *out_key) * @param out_key Key of the entry * @return Data of the entry * @protected - * @see DBIterator#prev + * @see struct DBIterator#prev() */ -struct DBData *dbit_obj_prev(DBIterator* self, union DBKey *out_key) +struct DBData *dbit_obj_prev(struct DBIterator *self, union DBKey *out_key) { - DBIterator_impl* it = (DBIterator_impl*)self; + struct DBIterator_impl *it = (struct DBIterator_impl *)self; DBNode *node; DBNode *parent; struct dbn fake; @@ -1440,11 +1440,11 @@ struct DBData *dbit_obj_prev(DBIterator* self, union DBKey *out_key) * @param self Iterator * @return true if the entry exists * @protected - * @see DBIterator#exists + * @see struct DBIterator#exists() */ -bool dbit_obj_exists(DBIterator* self) +bool dbit_obj_exists(struct DBIterator *self) { - DBIterator_impl* it = (DBIterator_impl*)self; + struct DBIterator_impl *it = (struct DBIterator_impl *)self; DB_COUNTSTAT(dbit_exists); return (it->node && !it->node->deleted); @@ -1452,19 +1452,21 @@ bool dbit_obj_exists(DBIterator* self) /** * Removes the current entry from the database. - * NOTE: {@link DBIterator#exists} will return false until another entry - * is fetched + * + * NOTE: struct DBIterator#exists() will return false until another entry is + * fetched. + * * Puts data of the removed entry in out_data, if out_data is not NULL (unless data has been released) * @param self Iterator * @param out_data Data of the removed entry. * @return 1 if entry was removed, 0 otherwise * @protected * @see DBMap#remove - * @see DBIterator#remove + * @see struct DBIterator#remove() */ -int dbit_obj_remove(DBIterator* self, struct DBData *out_data) +int dbit_obj_remove(struct DBIterator *self, struct DBData *out_data) { - DBIterator_impl* it = (DBIterator_impl*)self; + struct DBIterator_impl *it = (struct DBIterator_impl *)self; DBNode *node; int retval = 0; @@ -1489,9 +1491,9 @@ int dbit_obj_remove(DBIterator* self, struct DBData *out_data) * @param self Iterator * @protected */ -void dbit_obj_destroy(DBIterator* self) +void dbit_obj_destroy(struct DBIterator *self) { - DBIterator_impl* it = (DBIterator_impl*)self; + struct DBIterator_impl *it = (struct DBIterator_impl *)self; DB_COUNTSTAT(dbit_destroy); // unlock the database @@ -1509,10 +1511,10 @@ void dbit_obj_destroy(DBIterator* self) * @return New iterator * @protected */ -static DBIterator* db_obj_iterator(DBMap* self) +static struct DBIterator *db_obj_iterator(DBMap* self) { DBMap_impl* db = (DBMap_impl*)self; - DBIterator_impl* it; + struct DBIterator_impl *it; DB_COUNTSTAT(db_iterator); it = ers_alloc(db_iterator_ers, struct DBIterator_impl); diff --git a/src/common/db.h b/src/common/db.h index 1c2da3917..a867b011f 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -76,9 +76,9 @@ * DBComparator - Format of the comparators used by the databases. * * DBHasher - Format of the hashers used by the databases. * * DBReleaser - Format of the releasers used by the databases. * - * DBIterator - Database iterator. * + * struct DBIterator - Database iterator. * * DBMap - Database interface. * -\*****************************************************************************/ + *****************************************************************************/ /** * Bitfield with what should be released by the releaser function (if the @@ -288,21 +288,21 @@ typedef uint64 (*DBHasher)(union DBKey key, unsigned short maxlen); */ typedef void (*DBReleaser)(union DBKey key, struct DBData data, enum DBReleaseOption which); -typedef struct DBIterator DBIterator; typedef struct DBMap DBMap; /** * Database iterator. + * * Supports forward iteration, backward iteration and removing entries from the database. * The iterator is initially positioned before the first entry of the database. + * * While the iterator exists the database is locked internally, so invoke - * {@link DBIterator#destroy} as soon as possible. + * struct DBIterator#destroy() as soon as possible. + * * @public * @see #DBMap */ -struct DBIterator -{ - +struct DBIterator { /** * Fetches the first entry in the database. * Returns the data of the entry. @@ -312,7 +312,7 @@ struct DBIterator * @return Data of the entry * @protected */ - struct DBData *(*first)(DBIterator* self, union DBKey *out_key); + struct DBData *(*first)(struct DBIterator *self, union DBKey *out_key); /** * Fetches the last entry in the database. @@ -323,7 +323,7 @@ struct DBIterator * @return Data of the entry * @protected */ - struct DBData *(*last)(DBIterator* self, union DBKey *out_key); + struct DBData *(*last)(struct DBIterator *self, union DBKey *out_key); /** * Fetches the next entry in the database. @@ -334,7 +334,7 @@ struct DBIterator * @return Data of the entry * @protected */ - struct DBData *(*next)(DBIterator* self, union DBKey *out_key); + struct DBData *(*next)(struct DBIterator *self, union DBKey *out_key); /** * Fetches the previous entry in the database. @@ -345,7 +345,7 @@ struct DBIterator * @return Data of the entry * @protected */ - struct DBData *(*prev)(DBIterator* self, union DBKey *out_key); + struct DBData *(*prev)(struct DBIterator *self, union DBKey *out_key); /** * Returns true if the fetched entry exists. @@ -355,12 +355,14 @@ struct DBIterator * @return true is the entry exists * @protected */ - bool (*exists)(DBIterator* self); + bool (*exists)(struct DBIterator *self); /** * Removes the current entry from the database. - * NOTE: {@link DBIterator#exists} will return false until another entry - * is fetched + * + * NOTE: struct DBIterator#exists() will return false until another + * entry is fetched. + * * Puts data of the removed entry in out_data, if out_data is not NULL. * @param self Iterator * @param out_data Data of the removed entry. @@ -368,14 +370,14 @@ struct DBIterator * @protected * @see DBMap#remove */ - int (*remove)(DBIterator* self, struct DBData *out_data); + int (*remove)(struct DBIterator *self, struct DBData *out_data); /** * Destroys this iterator and unlocks the database. * @param self Iterator * @protected */ - void (*destroy)(DBIterator* self); + void (*destroy)(struct DBIterator *self); }; @@ -396,7 +398,7 @@ struct DBMap { * @return New iterator * @protected */ - DBIterator* (*iterator)(DBMap* self); + struct DBIterator *(*iterator)(DBMap* self); /** * Returns true if the entry exists. diff --git a/src/common/socket.c b/src/common/socket.c index 10712c78b..05ac4ca01 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1089,7 +1089,7 @@ static int connect_check_clear(int tid, int64 tick, int id, intptr_t data) { int clear = 0; int list = 0; ConnectHistory *hist = NULL; - DBIterator *iter; + struct DBIterator *iter; if( !db_size(connect_history) ) return 0; |