summaryrefslogtreecommitdiff
path: root/src/common/db.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-22 20:33:06 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-22 20:33:06 +0000
commit082687fc204c7b40bf676ad710c2488048571b73 (patch)
tree59b356c4d4cc86122ef42c46d9500ddeb93ba6bc /src/common/db.c
parenta31d779891778d76d1c0fac3544e6dd1627da98a (diff)
downloadhercules-082687fc204c7b40bf676ad710c2488048571b73.tar.gz
hercules-082687fc204c7b40bf676ad710c2488048571b73.tar.bz2
hercules-082687fc204c7b40bf676ad710c2488048571b73.tar.xz
hercules-082687fc204c7b40bf676ad710c2488048571b73.zip
Major cleanup all over the place, made possible by mkbu95's scan-build report he provided us with.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16687 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/db.c')
-rw-r--r--src/common/db.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/common/db.c b/src/common/db.c
index 999deea48..54834af81 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -1538,9 +1538,8 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
// Match in the order: current node, left tree, right tree
node = db->ht[i];
while (node) {
- parent = node->parent;
- if (!(node->deleted))
- {
+
+ if (!(node->deleted)) {
va_list argscopy;
va_copy(argscopy, args);
if (match(node->key, node->data, argscopy) == 0) {
@@ -1550,14 +1549,17 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
}
va_end(argscopy);
}
+
if (node->left) {
node = node->left;
continue;
}
+
if (node->right) {
node = node->right;
continue;
}
+
while (node) {
parent = node->parent;
if (parent && parent->right && parent->left == node) {
@@ -1566,6 +1568,7 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
}
node = parent;
}
+
}
}
db_free_unlock(db);
@@ -1923,9 +1926,7 @@ static int db_obj_vforeach(DBMap* self, DBApply func, va_list args)
// Apply func in the order: current node, left node, right node
node = db->ht[i];
while (node) {
- parent = node->parent;
- if (!(node->deleted))
- {
+ if (!(node->deleted)) {
va_list argscopy;
va_copy(argscopy, args);
sum += func(node->key, &node->data, argscopy);