summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authoramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-12-27 16:29:44 +0000
committeramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-12-27 16:29:44 +0000
commitb14ce328eaf0c82dff32ba156ec440ff1a07ac0d (patch)
tree2da3e570dda7049d4cca85c5b43e1c02577997bc /src/common
parent99b156f4ec91f2d52fd57aa1710ae9261b8db356 (diff)
downloadhercules-b14ce328eaf0c82dff32ba156ec440ff1a07ac0d.tar.gz
hercules-b14ce328eaf0c82dff32ba156ec440ff1a07ac0d.tar.bz2
hercules-b14ce328eaf0c82dff32ba156ec440ff1a07ac0d.tar.xz
hercules-b14ce328eaf0c82dff32ba156ec440ff1a07ac0d.zip
update
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@821 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/grfio.c7
-rw-r--r--src/common/malloc.c6
-rw-r--r--src/common/malloc.h16
-rw-r--r--src/common/utils.c5
4 files changed, 29 insertions, 5 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c
index f9d99bd70..ea5bba6ab 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -31,6 +31,7 @@
#include "grfio.h"
#include "mmo.h"
#include "showmsg.h"
+#include "malloc.h"
#ifdef MEMWATCH
#include "memwatch.h"
@@ -350,7 +351,7 @@ static FILELIST* filelist_add(FILELIST *entry)
}
if (filelist_entrys>=filelist_maxentry) {
- FILELIST *new_filelist = (FILELIST*)realloc(
+ FILELIST *new_filelist = (FILELIST*)aRealloc(
(void*)filelist, (filelist_maxentry+FILELIST_ADDS)*sizeof(FILELIST) );
if (new_filelist != NULL) {
filelist = new_filelist;
@@ -395,7 +396,7 @@ static void filelist_adjust(void)
{
if (filelist!=NULL) {
if (filelist_maxentry>filelist_entrys) {
- FILELIST *new_filelist = (FILELIST*)realloc(
+ FILELIST *new_filelist = (FILELIST*)aRealloc(
(void*)filelist,filelist_entrys*sizeof(FILELIST) );
if (new_filelist != NULL) {
filelist = new_filelist;
@@ -857,7 +858,7 @@ int grfio_add(char *fname)
// ShowStatus(tmp_output);
if (gentry_entrys>=gentry_maxentry) {
- char **new_gentry = (char**)realloc(
+ char **new_gentry = (char**)aRealloc(
(void*)gentry_table,(gentry_maxentry+GENTRY_ADDS)*sizeof(char*) );
if (new_gentry!=NULL) {
int lop;
diff --git a/src/common/malloc.c b/src/common/malloc.c
index eda9bc218..dd1be030f 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -42,3 +42,9 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f
}
return ret;
}
+
+void * _bcalloc(size_t size, size_t cnt) {
+ void *ret = malloc(size * cnt);
+ memset(ret, 0, size * cnt);
+ return ret;
+}
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 3733a5e55..7b09d7074 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -3,6 +3,21 @@
#include <stdlib.h>
+#if defined(GCOLLECT)
+
+#include "gc.h"
+#define aMalloc(n) GC_MALLOC(n)
+#define aCalloc(m,n) _bcalloc(m,n)
+#define aRealloc(p,n) GC_REALLOC(p,n)
+
+extern void * _bcalloc(size_t, size_t);
+
+#elif defined(BCHECK)
+#define aMalloc(n) malloc(n)
+#define aCalloc(m,n) calloc(m,n)
+#define aRealloc(p,n) realloc(p,n)
+#else
+
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
@@ -21,5 +36,6 @@ void* aRealloc_( void *p, size_t size, const char *file, int line, const char *f
#define aCalloc(m,n) aCalloc_(m,n,ALC_MARK)
#define aRealloc(p,n) aRealloc_(p,n,ALC_MARK)
+#endif
#endif
diff --git a/src/common/utils.c b/src/common/utils.c
index ccc81c1c5..9a7722478 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
+#include "malloc.h"
void dump(unsigned char *buffer, int num)
{
@@ -142,7 +143,7 @@ int StringBuf_Printf(struct StringBuf *sbuf,const char *fmt,...)
/* Else try again with more space. */
sbuf->max_ *= 2; // twice the old size
off = sbuf->ptr_ - sbuf->buf_;
- sbuf->buf_ = (char *) realloc(sbuf->buf_, sbuf->max_ + 1);
+ sbuf->buf_ = (char *) aRealloc(sbuf->buf_, sbuf->max_ + 1);
sbuf->ptr_ = sbuf->buf_ + off;
}
}
@@ -156,7 +157,7 @@ int StringBuf_Append(struct StringBuf *buf1,const struct StringBuf *buf2)
if (size2 >= buf1_avail) {
int off = buf1->ptr_ - buf1->buf_;
buf1->max_ += size2;
- buf1->buf_ = (char *) realloc(buf1->buf_, buf1->max_ + 1);
+ buf1->buf_ = (char *) aRealloc(buf1->buf_, buf1->max_ + 1);
buf1->ptr_ = buf1->buf_ + off;
}