svn commit: samba r2907 - in branches/SAMBA_4_0/source/lib: .
tridge at samba.org
tridge at samba.org
Mon Oct 11 05:23:46 GMT 2004
Author: tridge
Date: 2004-10-11 05:23:46 +0000 (Mon, 11 Oct 2004)
New Revision: 2907
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/lib&rev=2907&nolog=1
Log:
auto destroy iconv memory handles on exit, to make valgrind leak
reports easier to read (less noisy)
Modified:
branches/SAMBA_4_0/source/lib/charcnv.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/charcnv.c
===================================================================
--- branches/SAMBA_4_0/source/lib/charcnv.c 2004-10-11 05:17:21 UTC (rev 2906)
+++ branches/SAMBA_4_0/source/lib/charcnv.c 2004-10-11 05:23:46 UTC (rev 2907)
@@ -57,12 +57,38 @@
static smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS];
+/**
+ re-initialize iconv conversion descriptors
+**/
+void init_iconv(void)
+{
+ charset_t c1, c2;
+ for (c1=0;c1<NUM_CHARSETS;c1++) {
+ for (c2=0;c2<NUM_CHARSETS;c2++) {
+ if (conv_handles[c1][c2] != NULL) {
+ if (conv_handles[c1][c2] != (smb_iconv_t)-1) {
+ smb_iconv_close(conv_handles[c1][c2]);
+ }
+ conv_handles[c1][c2] = NULL;
+ }
+ }
+ }
+
+}
+
/*
on-demand initialisation of conversion handles
*/
static smb_iconv_t get_conv_handle(charset_t from, charset_t to)
{
const char *n1, *n2;
+ static int initialised;
+ /* auto-free iconv memory on exit so valgrind reports are easier
+ to look at */
+ if (initialised == 0) {
+ initialised = 1;
+ atexit(init_iconv);
+ }
if (conv_handles[from][to]) {
return conv_handles[from][to];
@@ -76,26 +102,7 @@
return conv_handles[from][to];
}
-/**
- re-initialize iconv conversion descriptors
-**/
-void init_iconv(void)
-{
- charset_t c1, c2;
- for (c1=0;c1<NUM_CHARSETS;c1++) {
- for (c2=0;c2<NUM_CHARSETS;c2++) {
- if (conv_handles[c1][c2] != NULL) {
- if (conv_handles[c1][c2] != (smb_iconv_t)-1) {
- smb_iconv_close(conv_handles[c1][c2]);
- }
- conv_handles[c1][c2] = NULL;
- }
- }
- }
-}
-
-
/**
* Convert string from one encoding to another, making error checking etc
*
More information about the samba-cvs
mailing list