diff libass/ass.c @ 24851:e36efda34616

Our enca code uses strdup() on the input encoding name, as we don't modify it we can use the original constant string. Uses less memory, code is simpler and faster. Fixes memory leak (noticed by ulion).
author iive
date Sun, 28 Oct 2007 14:26:05 +0000
parents d655edc9d107
children 892813c1b7e8
line wrap: on
line diff
--- a/libass/ass.c	Sat Oct 27 20:14:22 2007 +0000
+++ b/libass/ass.c	Sun Oct 28 14:26:05 2007 +0000
@@ -804,7 +804,7 @@
 	assert(codepage);
 
 	{
-		char* cp_tmp = codepage ? strdup(codepage) : 0;
+		const char* cp_tmp = codepage;
 #ifdef HAVE_ENCA
 		char enca_lang[3], enca_fallback[100];
 		if (sscanf(codepage, "enca:%2s:%99s", enca_lang, enca_fallback) == 2
@@ -816,9 +816,6 @@
 			mp_msg(MSGT_ASS,MSGL_V,"LIBSUB: opened iconv descriptor.\n");
 		} else
 			mp_msg(MSGT_ASS,MSGL_ERR,MSGTR_LIBASS_ErrorOpeningIconvDescriptor);
-#ifdef HAVE_ENCA
-		if (cp_tmp) free(cp_tmp);
-#endif
 	}
 
 	{