summaryrefslogtreecommitdiff
path: root/src/common/db.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-26 10:37:45 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-26 10:37:45 +0000
commit49e9510c432987393d10ec1b8b1c2d416c9feb42 (patch)
tree4d930ebf1094ad5972cb8ba20b89d12ce74d4f3c /src/common/db.c
parentfda87bd7ef5a71f4f5d5e604de1b15c58763efdd (diff)
downloadhercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.gz
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.bz2
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.xz
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.zip
Adjusted eAthena code to compile cleanly in C++ mode.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12436 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/db.c')
-rw-r--r--src/common/db.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/common/db.c b/src/common/db.c
index 77d3b7b2e..07adf73f1 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -107,6 +107,16 @@
#define HASH_SIZE (256+27)
/**
+ * The color of individual nodes.
+ * @private
+ * @see struct dbn
+ */
+typedef enum node_color {
+ RED,
+ BLACK
+} node_color;
+
+/**
* A node in a RED-BLACK tree of the database.
* @param parent Parent node
* @param left Left child node
@@ -127,7 +137,7 @@ typedef struct dbn {
DBKey key;
void *data;
// Other
- enum {RED, BLACK} color;
+ node_color color;
unsigned deleted : 1;
} *DBNode;
@@ -503,7 +513,7 @@ static void db_rebalance_erase(DBNode node, DBNode *root)
y->parent = node->parent;
// switch colors
{
- int tmp = y->color;
+ node_color tmp = y->color;
y->color = node->color;
node->color = tmp;
}
@@ -2112,7 +2122,7 @@ static DBType db_obj_type(DBMap* self)
DBType type;
DB_COUNTSTAT(db_type);
- if (db == NULL) return -1; // nullpo candidate - TODO what should this return?
+ if (db == NULL) return (DBType)-1; // nullpo candidate - TODO what should this return?
db_free_lock(db);
type = db->type;
@@ -2176,7 +2186,7 @@ DBOptions db_fix_options(DBType type, DBOptions options)
switch (type) {
case DB_INT:
case DB_UINT: // Numeric database, do nothing with the keys
- return options&~(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY);
+ return (DBOptions)(options&~(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY));
default:
ShowError("db_fix_options: Unknown database type %u with options %x\n", type, options);
@@ -2512,10 +2522,11 @@ void db_final(void)
}
// Link DB System - jAthena
-void linkdb_insert( struct linkdb_node** head, void *key, void* data) {
+void linkdb_insert( struct linkdb_node** head, void *key, void* data)
+{
struct linkdb_node *node;
if( head == NULL ) return ;
- node = aMalloc( sizeof(struct linkdb_node) );
+ node = (struct linkdb_node*)aMalloc( sizeof(struct linkdb_node) );
if( *head == NULL ) {
// first node
*head = node;
@@ -2532,7 +2543,8 @@ void linkdb_insert( struct linkdb_node** head, void *key, void* data) {
node->data = data;
}
-void* linkdb_search( struct linkdb_node** head, void *key) {
+void* linkdb_search( struct linkdb_node** head, void *key)
+{
int n = 0;
struct linkdb_node *node;
if( head == NULL ) return NULL;
@@ -2556,7 +2568,8 @@ void* linkdb_search( struct linkdb_node** head, void *key) {
return NULL;
}
-void* linkdb_erase( struct linkdb_node** head, void *key) {
+void* linkdb_erase( struct linkdb_node** head, void *key)
+{
struct linkdb_node *node;
if( head == NULL ) return NULL;
node = *head;
@@ -2577,7 +2590,8 @@ void* linkdb_erase( struct linkdb_node** head, void *key) {
return NULL;
}
-void linkdb_replace( struct linkdb_node** head, void *key, void *data ) {
+void linkdb_replace( struct linkdb_node** head, void *key, void *data )
+{
int n = 0;
struct linkdb_node *node;
if( head == NULL ) return ;
@@ -2603,7 +2617,8 @@ void linkdb_replace( struct linkdb_node** head, void *key, void *data ) {
linkdb_insert( head, key, data );
}
-void linkdb_final( struct linkdb_node** head ) {
+void linkdb_final( struct linkdb_node** head )
+{
struct linkdb_node *node, *node2;
if( head == NULL ) return ;
node = *head;