diff options
author | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-29 04:00:19 +0000 |
---|---|---|
committer | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-29 04:00:19 +0000 |
commit | 4db583138b9556f72b13df7f66eeeace6a67ce3e (patch) | |
tree | 72b6589e9f7a0e46e2aa459cd6272bb90bfe7e96 /src/common/grfio.c | |
parent | 525aa7d56ec5d74eac548d948782330d02df8f3e (diff) | |
download | hercules-4db583138b9556f72b13df7f66eeeace6a67ce3e.tar.gz hercules-4db583138b9556f72b13df7f66eeeace6a67ce3e.tar.bz2 hercules-4db583138b9556f72b13df7f66eeeace6a67ce3e.tar.xz hercules-4db583138b9556f72b13df7f66eeeace6a67ce3e.zip |
* Using malloc for memory allocations that doesn't need to be pre-initialized.
* Eliminated initializations for pointers returned by calloc.
* Moved grfio_final to do_init since it's not used after server boot.
* Optimized scripts to return CONSTSTR instead of allocating memory just to return a constant string. Some buildin functions still need work.
* Disabled graph since it doesn't work yet.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6355 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/grfio.c')
-rw-r--r-- | src/common/grfio.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c index eae06eada..d0178d3e4 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -591,7 +591,7 @@ void* grfio_reads(char *fname, int *size) lentry.declen = ftell(in);
}
fseek(in,0,0); // SEEK_SET
- buf2 = (unsigned char *)aCallocA(lentry.declen + 1024, 1);
+ buf2 = (unsigned char *)aMallocA(lentry.declen + 1024);
fread(buf2, 1, lentry.declen, in);
fclose(in);
strncpy(lentry.fn, fname, sizeof(lentry.fn) - 1);
@@ -611,11 +611,11 @@ void* grfio_reads(char *fname, int *size) char *gfname = gentry_table[entry->gentry - 1];
in = fopen(gfname, "rb");
if(in != NULL) {
- unsigned char *buf = (unsigned char *)aCallocA(entry->srclen_aligned + 1024, 1);
+ unsigned char *buf = (unsigned char *)aMallocA(entry->srclen_aligned + 1024);
fseek(in, entry->srcpos, 0);
fread(buf, 1, entry->srclen_aligned, in);
fclose(in);
- buf2 = (unsigned char *)aCallocA(entry->declen + 1024, 1);
+ buf2 = (unsigned char *)aMallocA(entry->declen + 1024);
if (entry->type == 1 || entry->type == 3 || entry->type == 5) {
uLongf len;
if (entry->cycle >= 0)
@@ -694,7 +694,7 @@ static int grfio_entryread(char *gfname,int gentry) if (grf_version == 0x01) { //****** Grf version 01xx ******
list_size = grf_size - ftell(fp);
- grf_filelist = (unsigned char *) aCallocA(list_size, 1);
+ grf_filelist = (unsigned char *) aMallocA(list_size);
/*if (grf_filelist == NULL){
fclose(fp);
ShowError("out of memory : grf_filelist\n");
@@ -770,13 +770,13 @@ static int grfio_entryread(char *gfname,int gentry) return 4;
}
- rBuf = (unsigned char *)aCallocA(rSize , 1); // Get a Read Size
+ rBuf = (unsigned char *)aMallocA(rSize); // Get a Read Size
/*if (rBuf==NULL) {
fclose(fp);
ShowError("out of memory : grf compress entry table buffer\n");
return 3;
}*/
- grf_filelist = (unsigned char *)aCallocA(eSize , 1); // Get a Extend Size
+ grf_filelist = (unsigned char *)aMallocA(eSize); // Get a Extend Size
/*if (grf_filelist==NULL) {
aFree(rBuf);
fclose(fp);
@@ -952,7 +952,7 @@ char *grfio_alloc_ptr(char *fname) memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS);
}
len = strlen( fname );
- buf = (char*)aCallocA(len + 1, 1);
+ buf = (char*)aMallocA(len + 1);
strcpy(buf, fname);
gentry_table[gentry_entrys++] = buf;
|