aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2010-07-20 15:28:22 +1000
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2010-07-20 15:28:22 +1000
commit8c4884d665595f633c542e889256d193b4faa487 (patch)
tree60524855581aec698a46ec3faec7fb4cacfeb9b6 /src
parentUse driver allocators in ejabberd_zlib_drv.c for reflecting memory in erlang:... (diff)
Use driver allocators in iconv_erl.c for reflecting memory in erlang:memory(system)
Diffstat (limited to 'src')
-rw-r--r--src/mod_irc/iconv_erl.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/mod_irc/iconv_erl.c b/src/mod_irc/iconv_erl.c
index 9e560610d..3212568d9 100644
--- a/src/mod_irc/iconv_erl.c
+++ b/src/mod_irc/iconv_erl.c
@@ -64,15 +64,15 @@ static int iconv_erl_control(ErlDrvData drv_data,
ei_decode_version(buf, &index, &i);
ei_decode_tuple_header(buf, &index, &i);
ei_get_type(buf, &index, &i, &size);
- from = malloc(size + 1);
+ from = driver_alloc(size + 1);
ei_decode_string(buf, &index, from);
ei_get_type(buf, &index, &i, &size);
- to = malloc(size + 1);
+ to = driver_alloc(size + 1);
ei_decode_string(buf, &index, to);
ei_get_type(buf, &index, &i, &size);
- stmp = string = malloc(size + 1);
+ stmp = string = driver_alloc(size + 1);
ei_decode_string(buf, &index, string);
/* Special mode: parse as UTF-8 if possible; otherwise assume it's
@@ -92,9 +92,9 @@ static int iconv_erl_control(ErlDrvData drv_data,
*rbuf = (char*)(b = driver_alloc_binary(size));
memcpy(b->orig_bytes, string, size);
- free(from);
- free(to);
- free(string);
+ driver_free(from);
+ driver_free(to);
+ driver_free(string);
return size;
}
@@ -102,7 +102,7 @@ static int iconv_erl_control(ErlDrvData drv_data,
outleft = avail = 4*size;
inleft = size;
- rtmp = rstring = malloc(avail);
+ rtmp = rstring = driver_alloc(avail);
while (inleft > 0) {
if (iconv(cd, &stmp, &inleft, &rtmp, &outleft) == (size_t) -1) {
if (invalid_utf8_as_latin1 && (*stmp & 0x80) && outleft >= 2) {
@@ -121,10 +121,10 @@ static int iconv_erl_control(ErlDrvData drv_data,
*rbuf = (char*)(b = driver_alloc_binary(size));
memcpy(b->orig_bytes, rstring, size);
- free(from);
- free(to);
- free(string);
- free(rstring);
+ driver_free(from);
+ driver_free(to);
+ driver_free(string);
+ driver_free(rstring);
iconv_close(cd);
return size;