diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-01 09:45:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:28 -0500 |
commit | f4dbe1865e714cb2fc87acbe6ab5f331ac9dbb1e (patch) | |
tree | a6a8aef07d779cc724d2a29ca7ee3649d1eee33b /source4/lib | |
parent | 5bab23d8ede8fb9baed125d6d681e0eca40c5030 (diff) | |
download | samba-f4dbe1865e714cb2fc87acbe6ab5f331ac9dbb1e.tar.gz samba-f4dbe1865e714cb2fc87acbe6ab5f331ac9dbb1e.tar.bz2 samba-f4dbe1865e714cb2fc87acbe6ab5f331ac9dbb1e.zip |
r2169: switch core iconv code to use talloc
(This used to be commit 117796c19ba9615113ae549068fd0b5ad5d3aa97)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/iconv.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/source4/lib/iconv.c b/source4/lib/iconv.c index 039dac2424..fb997cf8f1 100644 --- a/source4/lib/iconv.c +++ b/source4/lib/iconv.c @@ -179,15 +179,16 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) from = charsets; to = charsets; - ret = (smb_iconv_t)malloc(sizeof(*ret)); + ret = (smb_iconv_t)talloc_named(NULL, sizeof(*ret), + "iconv(%s,%s)", tocode, fromcode); if (!ret) { errno = ENOMEM; return (smb_iconv_t)-1; } memset(ret, 0, sizeof(*ret)); - ret->from_name = strdup(fromcode); - ret->to_name = strdup(tocode); + ret->from_name = talloc_strdup(ret, fromcode); + ret->to_name = talloc_strdup(ret, tocode); /* check for the simplest null conversion */ if (strcmp(fromcode, tocode) == 0) { @@ -258,7 +259,7 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) return ret; failed: - SAFE_FREE(ret); + talloc_free(ret); errno = EINVAL; return (smb_iconv_t)-1; } @@ -266,7 +267,7 @@ failed: /* simple iconv_close() wrapper */ -int smb_iconv_close (smb_iconv_t cd) +int smb_iconv_close(smb_iconv_t cd) { #ifdef HAVE_NATIVE_ICONV if (cd->cd_direct) iconv_close((iconv_t)cd->cd_direct); @@ -274,11 +275,7 @@ int smb_iconv_close (smb_iconv_t cd) if (cd->cd_push) iconv_close((iconv_t)cd->cd_push); #endif - SAFE_FREE(cd->from_name); - SAFE_FREE(cd->to_name); - - memset(cd, 0, sizeof(*cd)); - SAFE_FREE(cd); + talloc_free(cd); return 0; } @@ -699,3 +696,5 @@ error: return -1; } + + |