summaryrefslogtreecommitdiff
path: root/src/txt-converter
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-08 14:08:32 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-08 14:08:32 +0000
commitb5be01c5baca2d51da4ec9a138e3bb57eea7cbb4 (patch)
treeb7f079f5317d736e49fdf8b12f6d3f18b2a98daf /src/txt-converter
parentad2a3a12e2d603e8ef2011d1121271b7ed2f05eb (diff)
downloadhercules-b5be01c5baca2d51da4ec9a138e3bb57eea7cbb4.tar.gz
hercules-b5be01c5baca2d51da4ec9a138e3bb57eea7cbb4.tar.bz2
hercules-b5be01c5baca2d51da4ec9a138e3bb57eea7cbb4.tar.xz
hercules-b5be01c5baca2d51da4ec9a138e3bb57eea7cbb4.zip
* Changed EXIT_SUCCESS back to 0 in console.c to avoid an unnecessary include.
* Fixed gm_account_db not being deallocated in login-converter.c. * Refactoring names and documentation in db.h/db.c: - changed 'struct dbt' to 'struct DBMap' and 'DB' to 'DBMap*' - changed 'struct db' to 'struct DBMap_impl' and 'DB_impl' to 'DBMap_impl*' - changed COUNT to DB_COUNTSTAT and made it's existence not depend on DB_ENABLE_STATS - removed some @see links and corrected small typos in the documentation git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11698 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/txt-converter')
-rw-r--r--src/txt-converter/login-converter.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c
index 4a9b442f9..1e5aba76a 100644
--- a/src/txt-converter/login-converter.c
+++ b/src/txt-converter/login-converter.c
@@ -7,6 +7,7 @@
#include "../common/db.h"
#include "../common/showmsg.h"
#include "../common/sql.h"
+#include "../common/malloc.h"
#include <stdio.h>
#include <stdlib.h>
@@ -18,7 +19,7 @@ char login_user_pass[256]="user_pass";
char login_db[256]="login";
char globalreg_db[256]="global_reg_value";
-static struct dbt *gm_account_db;
+static DBMap* gm_account_db=NULL; // int account_id -> struct gm_account*
int db_server_port = 3306;
char db_server_ip[32] = "127.0.0.1";
@@ -52,7 +53,7 @@ int read_gm_account()
if( (fp = fopen(GM_ACCOUNT_NAME,"r")) == NULL )
return 1;
- gm_account_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); //FIXME: never deallocated
+ gm_account_db = idb_alloc(DB_OPT_RELEASE_DATA);
while(fgets(line,sizeof(line),fp))
{
@@ -60,7 +61,7 @@ int read_gm_account()
if ((line[0] == '/' && line[1] == '/') || line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
continue;
- p = (struct gm_account*)malloc(sizeof(struct gm_account));
+ p = (struct gm_account*)aMalloc(sizeof(struct gm_account));
if(p==NULL){
ShowFatalError("gm_account: out of memory!\n");
exit(EXIT_FAILURE);
@@ -73,7 +74,9 @@ int read_gm_account()
else {
if(p->level > 99)
p->level = 99;
- idb_put(gm_account_db,p->account_id,p);
+ p = idb_put(gm_account_db,p->account_id,p);
+ if( p )
+ aFree(p);// old entry replaced
gm_counter++;
ShowInfo("GM ID: %d Level: %d\n",p->account_id,p->level);
}
@@ -227,4 +230,11 @@ int do_init(int argc, char** argv)
void do_abort(void) {}
-void do_final(void) {}
+void do_final(void)
+{
+ if( gm_account_db )
+ {
+ db_destroy(gm_account_db);
+ gm_account_db = NULL;
+ }
+}