Fixed a error where logging callback could be set to NULL and added some explaining comments.
git-svn-id: http://liblouis.googlecode.com/svn/trunk@1156 24698d54-e344-0410-af24-25bd253c2c7b
diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c
index 777a7c0..c55c176 100644
--- a/liblouis/compileTranslationTable.c
+++ b/liblouis/compileTranslationTable.c
@@ -5173,7 +5173,8 @@
{
if (callback == 0)
logCallbackFunction = defaultLogCallback;
- logCallbackFunction = callback;
+ else
+ logCallbackFunction = callback;
}
static logLevels logLevel = LOG_INFO;
@@ -5209,6 +5210,14 @@
void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen)
{
+ /* When calculating output size:
+ * Each wdiechar is represented in hex, thus needing two bytes for each
+ * byte in the widechar (sizeof(widechar) * 2)
+ * Allow space for the "0x%X " formatting (+ 3)
+ * Number of characters in widechar buffer (wlen * )
+ * Give space for additional message (+ strlen(msg))
+ * Remember the null terminator (+ 1)
+ */
int logBufSize = (wlen * ((sizeof(widechar) * 2) + 3)) + 1 + strlen(msg);
char *logMessage = malloc(logBufSize);
char *p = logMessage;