warning in _localemodule.c patch

You can't free the memory Py_FSDE points to, since it wasn't allocated by malloc().
Why is that? The memory was allocated by strdup in this case, so you can certainly free() it.
I guess the simple solution is to remove the const. Is there a better option?
The other option is to cast the pointer in the call to free(). I don't know which one is better; Py_FSDE certainly points to memory that should not be changed. Regards, Martin

The other option is to cast the pointer in the call to free().
Sounds like the better solution. Publicly, it's a const. Privately, you happen to malloc() and free() it. --Guido van Rossum (home page: http://www.python.org/~guido/)

"GvR" == Guido van Rossum <guido@python.org> writes:
The other option is to cast the pointer in the call to free(). GvR> Sounds like the better solution.
GvR> Publicly, it's a const. Privately, you happen to malloc() and GvR> free() it. I'm not sure about the intersection of all the ifdefs. Is it possible to execute the new code in the localmodule on Win32? I was looking at the first value which is the literal "mbcs", which shouldn't be passed to free. Jeremy

I'm not sure about the intersection of all the ifdefs. Is it possible to execute the new code in the localmodule on Win32? I was looking at the first value which is the literal "mbcs", which shouldn't be passed to free.
It's not possible, since there is no langinfo.h on Windows. Even if that was (which may be the case for cygwin, dunno), it will only use nl_langinfo(CODESET), strdup, and free, if it ever found Py_FSDE to be NULL. If you through the code the first time and Py_FSDE is already set, it won't attempt to change it, or free its current value. Since the code appears not to be obvious, I think I shall put a comment into it. Regards, Martin
participants (3)
-
Guido van Rossum
-
Jeremy Hylton
-
Martin von Loewis