diff options
author | amber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-12-29 19:18:18 +0000 |
---|---|---|
committer | amber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-12-29 19:18:18 +0000 |
commit | ab0a9edc2f5754c4f778c008caff1682d43d65eb (patch) | |
tree | 639e173ce8010bd59ddddb5460fdc56858a1ac1a /src/common | |
parent | e5bce970b13d3485cfa823aa4810787c2006181a (diff) | |
download | hercules-ab0a9edc2f5754c4f778c008caff1682d43d65eb.tar.gz hercules-ab0a9edc2f5754c4f778c008caff1682d43d65eb.tar.bz2 hercules-ab0a9edc2f5754c4f778c008caff1682d43d65eb.tar.xz hercules-ab0a9edc2f5754c4f778c008caff1682d43d65eb.zip |
cxx updates
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@861 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/db.c | 1 | ||||
-rw-r--r-- | src/common/grfio.c | 36 | ||||
-rw-r--r-- | src/common/grfio.h | 4 | ||||
-rw-r--r-- | src/common/mmo.h | 6 | ||||
-rw-r--r-- | src/common/socket.c | 12 | ||||
-rw-r--r-- | src/common/socket.h | 1 | ||||
-rw-r--r-- | src/common/strlib.c | 1 | ||||
-rw-r--r-- | src/common/utils.h | 4 |
8 files changed, 34 insertions, 31 deletions
diff --git a/src/common/db.c b/src/common/db.c index 8996dda80..bc4e8451b 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -6,6 +6,7 @@ #include "db.h" #include "mmo.h" #include "utils.h" +#include "malloc.h" #ifdef MEMWATCH #include "memwatch.h" diff --git a/src/common/grfio.c b/src/common/grfio.c index 37cf2b9ee..440c3b2a3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -284,7 +284,7 @@ static void decode_des_etc(BYTE *buf,int len,int type,int cycle) * Grf data decode sub : zip *------------------------------------------ */ -int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) +int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -294,7 +294,7 @@ int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - stream.next_out = dest; + stream.next_out = (Bytef*) dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; @@ -315,7 +315,7 @@ int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned return err; } -int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen) { +int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { z_stream stream; int err; @@ -324,7 +324,7 @@ int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - stream.next_out = dest; + stream.next_out = (Bytef*) dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; @@ -382,7 +382,7 @@ FILELIST *filelist_find(char *fname) { int hash; - for(hash=filelist_hash[filehash(fname)];hash>=0;hash=filelist[hash].next) { + for(hash=filelist_hash[filehash((unsigned char *) fname)];hash>=0;hash=filelist[hash].next) { if(strcmpi(filelist[hash].fn,fname)==0) break; } @@ -421,7 +421,7 @@ static FILELIST* filelist_add(FILELIST *entry) memcpy( &filelist[filelist_entrys], entry, sizeof(FILELIST) ); - hash = filehash(entry->fn); + hash = filehash((unsigned char *) entry->fn); filelist[filelist_entrys].next = filelist_hash[hash]; filelist_hash[hash] = filelist_entrys; @@ -576,7 +576,7 @@ void* grfio_reads(char *fname, int *size) lentry.declen = ftell(in); } fseek(in,0,0); // SEEK_SET - buf2 = calloc(lentry.declen+1024, 1); + buf2 = (unsigned char *) aCalloc(lentry.declen+1024, 1); if (buf2==NULL) { printf("file read memory allocate error : declen\n"); goto errret; @@ -598,7 +598,7 @@ void* grfio_reads(char *fname, int *size) } } if (entry!=NULL && entry->gentry>0) { // Archive[GRF] File Read - buf = calloc(entry->srclen_aligned+1024, 1); + buf = (unsigned char *) aCalloc(entry->srclen_aligned+1024, 1); if (buf==NULL) { printf("file read memory allocate error : srclen_aligned\n"); goto errret; @@ -614,7 +614,7 @@ void* grfio_reads(char *fname, int *size) fseek(in,entry->srcpos,0); fread(buf,1,entry->srclen_aligned,in); fclose(in); - buf2=calloc(entry->declen+1024, 1); + buf2 = (unsigned char *) aCalloc(entry->declen+1024, 1); if (buf2==NULL) { printf("file decode memory allocate error\n"); goto errret; @@ -694,7 +694,7 @@ static int grfio_entryread(char *gfname,int gentry) grf_size = ftell(fp); fseek(fp,0,0); // SEEK_SET fread(grf_header,1,0x2e,fp); - if(strcmp(grf_header,"Master of Magic") || fseek(fp,getlong(grf_header+0x1e),1)){ // SEEK_CUR + if(strcmp((const char *) grf_header,"Master of Magic") || fseek(fp,getlong(grf_header+0x1e),1)){ // SEEK_CUR fclose(fp); printf("%s read error\n",gfname); return 2; // 2:file format error @@ -704,7 +704,7 @@ static int grfio_entryread(char *gfname,int gentry) if (grf_version==0x01) { //****** Grf version 01xx ****** list_size = grf_size-ftell(fp); - grf_filelist = calloc(list_size, 1); + grf_filelist = (unsigned char *) aCalloc(list_size, 1); if(grf_filelist==NULL){ fclose(fp); printf("out of memory : grf_filelist\n"); @@ -725,13 +725,13 @@ static int grfio_entryread(char *gfname,int gentry) type = grf_filelist[ofs2+12]; if( type!=0 ){ // Directory Index ... skip fname = decode_filename(grf_filelist+ofs+6,grf_filelist[ofs]-6); - if(strlen(fname)>sizeof(aentry.fn)-1){ + if(strlen((const char *) fname)>sizeof(aentry.fn)-1){ printf("file name too long : %s\n",fname); free(grf_filelist); exit(1); } srclen=0; - if((period_ptr=strrchr(fname,'.'))!=NULL){ + if((period_ptr=strrchr((const char *) fname,'.'))!=NULL){ for(lop=0;lop<4;lop++) { if(strcmpi(period_ptr,".gnd\0.gat\0.act\0.str"+lop*5)==0) break; @@ -752,7 +752,7 @@ static int grfio_entryread(char *gfname,int gentry) aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; aentry.cycle = srccount; aentry.type = type; - strncpy(aentry.fn,fname,sizeof(aentry.fn)-1); + strncpy(aentry.fn, (const char *) fname,sizeof(aentry.fn)-1); #ifdef GRFIO_LOCAL aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck #else @@ -779,13 +779,13 @@ static int grfio_entryread(char *gfname,int gentry) return 4; } - rBuf = calloc( rSize , 1); // Get a Read Size + rBuf = (unsigned char *) aCalloc( rSize , 1); // Get a Read Size if (rBuf==NULL) { fclose(fp); printf("out of memory : grf compress entry table buffer\n"); return 3; } - grf_filelist = calloc( eSize , 1); // Get a Extend Size + grf_filelist = (unsigned char *) aCalloc( eSize , 1); // Get a Extend Size if (grf_filelist==NULL) { free(rBuf); fclose(fp); @@ -806,7 +806,7 @@ static int grfio_entryread(char *gfname,int gentry) FILELIST aentry; fname = grf_filelist+ofs; - if (strlen(fname)>sizeof(aentry.fn)-1) { + if (strlen((const char *) fname)>sizeof(aentry.fn)-1) { printf("grf : file name too long : %s\n",fname); free(grf_filelist); exit(1); @@ -927,7 +927,7 @@ int grfio_add(char *fname) } } len = strlen( fname ); - buf = calloc(len+1, 1); + buf = aCalloc(len+1, 1); if (buf==NULL) { printf("out of memory : gentry\n"); exit(1); diff --git a/src/common/grfio.h b/src/common/grfio.h index f39e9af1b..3fa257e2f 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -8,8 +8,8 @@ void* grfio_read(char*); // GRFIO data file read void* grfio_reads(char*,int*); // GRFIO data file read & size get int grfio_size(char*); // GRFIO data file size get -int decode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen); -int encode_zip(char *dest, unsigned long* destLen, const char* source, unsigned long sourceLen); +int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); +int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); // Accessor to GRF filenames char *grfio_setdatafile(const char *str); diff --git a/src/common/mmo.h b/src/common/mmo.h index 617a870e9..41598509e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -114,7 +114,7 @@ struct s_pet { int account_id; int char_id; int pet_id; - short class; + short class_; short level; short egg_id;//pet egg id short equip;//pet equip name_id @@ -132,7 +132,7 @@ struct mmo_charstatus { int base_exp,job_exp,zeny; - short class; + short class_; short status_point,skill_point; int hp,max_hp,sp,max_sp; short option,karma,manner; @@ -204,7 +204,7 @@ struct party { struct guild_member { int account_id, char_id; - short hair,hair_color,gender,class,lv; + short hair,hair_color,gender,class_,lv; int exp,exp_payper; short online,position; int rsv1,rsv2; diff --git a/src/common/socket.c b/src/common/socket.c index 729f2fdfe..5d7d0775e 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -200,8 +200,8 @@ static int connect_client(int listen_fd) #endif CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, char, rfifo_size); - CREATE(session[fd]->wdata, char, wfifo_size); + CREATE(session[fd]->rdata, unsigned char, rfifo_size); + CREATE(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -339,8 +339,8 @@ int make_connection(long ip,int port) FD_SET(fd,&readfds); CREATE(session[fd], struct socket_data, 1); - CREATE(session[fd]->rdata, char, rfifo_size); - CREATE(session[fd]->wdata, char, wfifo_size); + CREATE(session[fd]->rdata, unsigned char, rfifo_size); + CREATE(session[fd]->wdata, unsigned char, wfifo_size); session[fd]->max_rdata = rfifo_size; session[fd]->max_wdata = wfifo_size; @@ -374,11 +374,11 @@ int realloc_fifo(int fd,int rfifo_size,int wfifo_size) { struct socket_data *s=session[fd]; if( s->max_rdata != rfifo_size && s->rdata_size < rfifo_size){ - RECREATE(s->rdata, char, rfifo_size); + RECREATE(s->rdata, unsigned char, rfifo_size); s->max_rdata = rfifo_size; } if( s->max_wdata != wfifo_size && s->wdata_size < wfifo_size){ - RECREATE(s->wdata, char, wfifo_size); + RECREATE(s->wdata, unsigned char, wfifo_size); s->max_wdata = wfifo_size; } return 0; diff --git a/src/common/socket.h b/src/common/socket.h index 9b0c05013..e5e065f33 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -12,6 +12,7 @@ #include <sys/socket.h> #include <netinet/in.h> #endif +#include "malloc.h" // define declaration diff --git a/src/common/strlib.c b/src/common/strlib.c index b113d96f5..9114c3d03 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -4,6 +4,7 @@ #include "strlib.h" #include "utils.h" +#include "malloc.h" //----------------------------------------------- // string lib. diff --git a/src/common/utils.h b/src/common/utils.h index d234e9351..0ac880a50 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -27,11 +27,11 @@ #define CREATE(result, type, number) do {\ if ((number) * sizeof(type) <= 0) \ printf("SYSERR: Zero bytes or less requested at %s:%d.\n", __FILE__, __LINE__); \ - if (!((result) = (type *) calloc ((number), sizeof(type)))) \ + if (!((result) = (type *) aCalloc ((number), sizeof(type)))) \ { perror("SYSERR: malloc failure"); abort(); } } while(0) #define RECREATE(result,type,number) do {\ - if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\ + if (!((result) = (type *) aRealloc ((result), sizeof(type) * (number))))\ { printf("SYSERR: realloc failure"); abort(); } } while(0) struct StringBuf { |