A malloc() pass on WinPR

This patch treats remaining non-checked mallocs. And changes to calloc in places
where it makes sense
This commit is contained in:
David FORT 2015-06-14 00:55:09 +02:00 committed by Bernhard Miklautz
parent 749d93ae39
commit 16d36e3083
19 changed files with 179 additions and 191 deletions

3
.gitignore vendored
View File

@ -132,6 +132,9 @@ TAGS
# packaging related files
!packaging/scripts/prepare_deb_freerdp-nightly.sh
packaging/deb/freerdp-nightly/freerdp-nightly
packaging/deb/freerdp-nightly/freerdp-nightly-dev
packaging/deb/freerdp-nightly/freerdp-nightly-dbg
#
.idea

View File

@ -317,7 +317,7 @@ WINPR_API DWORD WLog_GetLogLevel(wLog* log);
WINPR_API void WLog_SetLogLevel(wLog* log, DWORD logLevel);
WINPR_API wLogAppender* WLog_GetLogAppender(wLog* log);
WINPR_API void WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType);
WINPR_API BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType);
WINPR_API int WLog_OpenAppender(wLog* log);
WINPR_API int WLog_CloseAppender(wLog* log);
@ -337,7 +337,7 @@ WINPR_API BOOL WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout, const
WINPR_API wLog* WLog_GetRoot(void);
WINPR_API wLog* WLog_Get(LPCSTR name);
WINPR_API void WLog_Init(void);
WINPR_API BOOL WLog_Init(void);
WINPR_API void WLog_Uninit(void);
#ifdef __cplusplus

View File

@ -73,11 +73,10 @@ ASN1error_e ASN1_CreateEncoder(ASN1module_t pModule, ASN1encoding_t* ppEncoderIn
if (pModule && ppEncoderInfo)
{
*ppEncoderInfo = 0;
encoder = (ASN1encoding_t) malloc(sizeof(struct ASN1encoding_s));
encoder = (ASN1encoding_t) calloc(1, sizeof(struct ASN1encoding_s));
if (encoder)
{
ZeroMemory(encoder, sizeof(struct ASN1encoding_s));
encoder->magic = 0x44434E45;
encoder->err = ASN1_SUCCESS;
encoder->dwFlags = pModule->dwFlags;

View File

@ -161,12 +161,10 @@ HCERTSTORE CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingTyp
{
WINPR_CERTSTORE* certstore;
certstore = (WINPR_CERTSTORE*) malloc(sizeof(WINPR_CERTSTORE));
certstore = (WINPR_CERTSTORE*) calloc(1, sizeof(WINPR_CERTSTORE));
if (certstore)
{
ZeroMemory(certstore, sizeof(WINPR_CERTSTORE));
certstore->lpszStoreProvider = lpszStoreProvider;
certstore->dwMsgAndCertEncodingType = dwMsgAndCertEncodingType;
}

View File

@ -84,12 +84,9 @@ PTEB NtCurrentTeb(void)
{
if ((teb = pthread_getspecific(_TebKey)) == NULL)
{
teb = malloc(sizeof(TEB));
teb = calloc(1, sizeof(TEB));
if (teb)
{
ZeroMemory(teb, sizeof(TEB));
pthread_setspecific(_TebKey, teb);
}
}
}
return teb;

View File

@ -135,7 +135,7 @@ static void* named_pipe_server_thread(void* arg)
goto out;
}
if (!(lpReadBuffer = (BYTE*) malloc(PIPE_BUFFER_SIZE)))
if (!(lpReadBuffer = (BYTE*) calloc(1, PIPE_BUFFER_SIZE)))
{
printf("%s: Error allocating read buffer\n", __FUNCTION__);
goto out;
@ -149,7 +149,6 @@ static void* named_pipe_server_thread(void* arg)
lpNumberOfBytesRead = 0;
nNumberOfBytesToRead = PIPE_BUFFER_SIZE;
ZeroMemory(lpReadBuffer, PIPE_BUFFER_SIZE);
if (!ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, &lpNumberOfBytesRead, NULL) ||
lpNumberOfBytesRead != nNumberOfBytesToRead)

View File

@ -170,7 +170,7 @@ static void* named_pipe_server_thread(void* arg)
return NULL;
}
lpReadBuffer = (BYTE*) malloc(PIPE_BUFFER_SIZE);
lpReadBuffer = (BYTE*) calloc(1, PIPE_BUFFER_SIZE);
lpWriteBuffer = (BYTE*) malloc(PIPE_BUFFER_SIZE);
if (!lpReadBuffer || !lpWriteBuffer)
{
@ -180,7 +180,6 @@ static void* named_pipe_server_thread(void* arg)
return NULL;
}
nNumberOfBytesToRead = PIPE_BUFFER_SIZE;
ZeroMemory(lpReadBuffer, PIPE_BUFFER_SIZE);
fSuccess = ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, NULL, &overlapped);
if (!fSuccess)

View File

@ -34,13 +34,15 @@ SCHANNEL_CONTEXT* schannel_ContextNew()
{
SCHANNEL_CONTEXT* context;
context = (SCHANNEL_CONTEXT*) malloc(sizeof(SCHANNEL_CONTEXT));
context = (SCHANNEL_CONTEXT*) calloc(1, sizeof(SCHANNEL_CONTEXT));
if (!context)
return NULL;
if (context != NULL)
context->openssl = schannel_openssl_new();
if (!context->openssl)
{
ZeroMemory(context, sizeof(SCHANNEL_CONTEXT));
context->openssl = schannel_openssl_new();
free(context);
return NULL;
}
return context;
@ -60,12 +62,7 @@ SCHANNEL_CREDENTIALS* schannel_CredentialsNew()
{
SCHANNEL_CREDENTIALS* credentials;
credentials = (SCHANNEL_CREDENTIALS*) malloc(sizeof(SCHANNEL_CREDENTIALS));
if (credentials != NULL)
{
ZeroMemory(credentials, sizeof(SCHANNEL_CREDENTIALS));
}
credentials = (SCHANNEL_CREDENTIALS*) calloc(1, sizeof(SCHANNEL_CREDENTIALS));
return credentials;
}

View File

@ -240,10 +240,9 @@ int schannel_send(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle phCont
ZeroMemory(&StreamSizes, sizeof(SecPkgContext_StreamSizes));
status = table->QueryContextAttributes(phContext, SECPKG_ATTR_STREAM_SIZES, &StreamSizes);
ioBufferLength = StreamSizes.cbHeader + StreamSizes.cbMaximumMessage + StreamSizes.cbTrailer;
ioBuffer = (BYTE*) malloc(ioBufferLength);
ioBuffer = (BYTE*) calloc(1, ioBufferLength);
if (!ioBuffer)
return -1;
ZeroMemory(ioBuffer, ioBufferLength);
pMessageBuffer = ioBuffer + StreamSizes.cbHeader;
CopyMemory(pMessageBuffer, buffer, length);
Buffers[0].pvBuffer = ioBuffer;
@ -298,10 +297,9 @@ int schannel_recv(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle phCont
ZeroMemory(&StreamSizes, sizeof(SecPkgContext_StreamSizes));
status = table->QueryContextAttributes(phContext, SECPKG_ATTR_STREAM_SIZES, &StreamSizes);
ioBufferLength = StreamSizes.cbHeader + StreamSizes.cbMaximumMessage + StreamSizes.cbTrailer;
ioBuffer = (BYTE*) malloc(ioBufferLength);
ioBuffer = (BYTE*) malloc(1, ioBufferLength);
if (!ioBuffer)
return -1;
ZeroMemory(ioBuffer, ioBufferLength);
if (!ReadFile(hPipe, ioBuffer, ioBufferLength, &NumberOfBytesRead, NULL))
{

View File

@ -608,11 +608,10 @@ HANDLE CreateTimerQueue(void)
{
HANDLE handle = NULL;
WINPR_TIMER_QUEUE* timerQueue;
timerQueue = (WINPR_TIMER_QUEUE*) malloc(sizeof(WINPR_TIMER_QUEUE));
timerQueue = (WINPR_TIMER_QUEUE*) calloc(1, sizeof(WINPR_TIMER_QUEUE));
if (timerQueue)
{
ZeroMemory(timerQueue, sizeof(WINPR_TIMER_QUEUE));
WINPR_HANDLE_SET_TYPE(timerQueue, HANDLE_TYPE_TIMER_QUEUE);
handle = (HANDLE) timerQueue;
timerQueue->activeHead = NULL;

View File

@ -323,16 +323,7 @@ wLinkedList* LinkedList_New()
{
wLinkedList* list = NULL;
list = (wLinkedList*) malloc(sizeof(wLinkedList));
if (list)
{
list->count = 0;
list->initial = 0;
list->head = NULL;
list->tail = NULL;
list->current = NULL;
}
list = (wLinkedList*) calloc(1, sizeof(wLinkedList));
return list;
}

View File

@ -158,31 +158,38 @@ wReferenceTable* ReferenceTable_New(BOOL synchronized, void* context, REFERENCE_
wReferenceTable* referenceTable;
referenceTable = (wReferenceTable*) malloc(sizeof(wReferenceTable));
if (!referenceTable)
return NULL;
if (referenceTable)
{
referenceTable->array = (wReference*) calloc(1, sizeof(wReference) * referenceTable->size);
if (!referenceTable->array)
{
free(referenceTable);
return NULL;
}
referenceTable->context = context;
referenceTable->ReferenceFree = ReferenceFree;
referenceTable->array = (wReference*) calloc(1, sizeof(wReference) * referenceTable->size);
if (!referenceTable->array)
goto error_array;
referenceTable->size = 32;
referenceTable->context = context;
referenceTable->ReferenceFree = ReferenceFree;
referenceTable->synchronized = synchronized;
InitializeCriticalSectionAndSpinCount(&referenceTable->lock, 4000);
}
referenceTable->size = 32;
referenceTable->synchronized = synchronized;
if (synchronized && !InitializeCriticalSectionAndSpinCount(&referenceTable->lock, 4000))
goto error_critical_section;
return referenceTable;
error_critical_section:
free(referenceTable->array);
error_array:
free(referenceTable);
return NULL;
}
void ReferenceTable_Free(wReferenceTable* referenceTable)
{
if (referenceTable)
{
if (referenceTable->synchronized)
DeleteCriticalSection(&referenceTable->lock);
DeleteCriticalSection(&referenceTable->lock);
free(referenceTable->array);
free(referenceTable);

View File

@ -109,7 +109,7 @@ wLogAppender* WLog_GetLogAppender(wLog* log)
return log->Appender;
}
void WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType)
BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType)
{
if (log->Appender)
{
@ -118,6 +118,7 @@ void WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType)
}
log->Appender = WLog_Appender_New(log, logAppenderType);
return log->Appender != NULL;
}
int WLog_OpenAppender(wLog* log)

View File

@ -192,28 +192,19 @@ wLogBinaryAppender* WLog_BinaryAppender_New(wLog* log)
{
wLogBinaryAppender* BinaryAppender;
BinaryAppender = (wLogBinaryAppender*) malloc(sizeof(wLogBinaryAppender));
BinaryAppender = (wLogBinaryAppender*) calloc(1, sizeof(wLogBinaryAppender));
if (!BinaryAppender)
return NULL;
if (BinaryAppender)
{
ZeroMemory(BinaryAppender, sizeof(wLogBinaryAppender));
BinaryAppender->Type = WLOG_APPENDER_BINARY;
BinaryAppender->Open = (WLOG_APPENDER_OPEN_FN) WLog_BinaryAppender_Open;
BinaryAppender->Close = (WLOG_APPENDER_OPEN_FN) WLog_BinaryAppender_Close;
BinaryAppender->WriteMessage =
(WLOG_APPENDER_WRITE_MESSAGE_FN) WLog_BinaryAppender_WriteMessage;
BinaryAppender->WriteDataMessage =
(WLOG_APPENDER_WRITE_DATA_MESSAGE_FN) WLog_BinaryAppender_WriteDataMessage;
BinaryAppender->WriteImageMessage =
(WLOG_APPENDER_WRITE_IMAGE_MESSAGE_FN) WLog_BinaryAppender_WriteImageMessage;
BinaryAppender->FileName = NULL;
BinaryAppender->FilePath = NULL;
BinaryAppender->FullFileName = NULL;
}
BinaryAppender->Type = WLOG_APPENDER_BINARY;
BinaryAppender->Open = (WLOG_APPENDER_OPEN_FN) WLog_BinaryAppender_Open;
BinaryAppender->Close = (WLOG_APPENDER_OPEN_FN) WLog_BinaryAppender_Close;
BinaryAppender->WriteMessage =
(WLOG_APPENDER_WRITE_MESSAGE_FN) WLog_BinaryAppender_WriteMessage;
BinaryAppender->WriteDataMessage =
(WLOG_APPENDER_WRITE_DATA_MESSAGE_FN) WLog_BinaryAppender_WriteDataMessage;
BinaryAppender->WriteImageMessage =
(WLOG_APPENDER_WRITE_IMAGE_MESSAGE_FN) WLog_BinaryAppender_WriteImageMessage;
return BinaryAppender;
}

View File

@ -125,31 +125,22 @@ wLogCallbackAppender* WLog_CallbackAppender_New(wLog* log)
{
wLogCallbackAppender* CallbackAppender;
CallbackAppender = (wLogCallbackAppender*) malloc(sizeof(wLogCallbackAppender));
CallbackAppender = (wLogCallbackAppender*) calloc(1, sizeof(wLogCallbackAppender));
if (!CallbackAppender)
return NULL;
if (CallbackAppender)
{
ZeroMemory(CallbackAppender, sizeof(wLogCallbackAppender));
CallbackAppender->Type = WLOG_APPENDER_CALLBACK;
CallbackAppender->Type = WLOG_APPENDER_CALLBACK;
CallbackAppender->Open = (WLOG_APPENDER_OPEN_FN) WLog_CallbackAppender_Open;
CallbackAppender->Close = (WLOG_APPENDER_OPEN_FN) WLog_CallbackAppender_Close;
CallbackAppender->WriteMessage =
(WLOG_APPENDER_WRITE_MESSAGE_FN) WLog_CallbackAppender_WriteMessage;
CallbackAppender->WriteDataMessage =
(WLOG_APPENDER_WRITE_DATA_MESSAGE_FN) WLog_CallbackAppender_WriteDataMessage;
CallbackAppender->WriteImageMessage =
(WLOG_APPENDER_WRITE_IMAGE_MESSAGE_FN) WLog_CallbackAppender_WriteImageMessage;
CallbackAppender->WritePacketMessage =
(WLOG_APPENDER_WRITE_PACKET_MESSAGE_FN) WLog_CallbackAppender_WritePacketMessage;
CallbackAppender->message = NULL;
CallbackAppender->image = NULL;
CallbackAppender->package = NULL;
CallbackAppender->data = NULL;
}
CallbackAppender->Open = (WLOG_APPENDER_OPEN_FN) WLog_CallbackAppender_Open;
CallbackAppender->Close = (WLOG_APPENDER_OPEN_FN) WLog_CallbackAppender_Close;
CallbackAppender->WriteMessage =
(WLOG_APPENDER_WRITE_MESSAGE_FN) WLog_CallbackAppender_WriteMessage;
CallbackAppender->WriteDataMessage =
(WLOG_APPENDER_WRITE_DATA_MESSAGE_FN) WLog_CallbackAppender_WriteDataMessage;
CallbackAppender->WriteImageMessage =
(WLOG_APPENDER_WRITE_IMAGE_MESSAGE_FN) WLog_CallbackAppender_WriteImageMessage;
CallbackAppender->WritePacketMessage =
(WLOG_APPENDER_WRITE_PACKET_MESSAGE_FN) WLog_CallbackAppender_WritePacketMessage;
return CallbackAppender;
}

View File

@ -195,57 +195,62 @@ wLogFileAppender* WLog_FileAppender_New(wLog* log)
LPCSTR name;
DWORD nSize;
wLogFileAppender* FileAppender;
BOOL status;
FileAppender = (wLogFileAppender*) malloc(sizeof(wLogFileAppender));
FileAppender = (wLogFileAppender*) calloc(1, sizeof(wLogFileAppender));
if (!FileAppender)
return NULL;
if (FileAppender)
FileAppender->Type = WLOG_APPENDER_FILE;
FileAppender->Open = (WLOG_APPENDER_OPEN_FN) WLog_FileAppender_Open;
FileAppender->Close = (WLOG_APPENDER_OPEN_FN) WLog_FileAppender_Close;
FileAppender->WriteMessage =
(WLOG_APPENDER_WRITE_MESSAGE_FN) WLog_FileAppender_WriteMessage;
FileAppender->WriteDataMessage =
(WLOG_APPENDER_WRITE_DATA_MESSAGE_FN) WLog_FileAppender_WriteDataMessage;
FileAppender->WriteImageMessage =
(WLOG_APPENDER_WRITE_IMAGE_MESSAGE_FN) WLog_FileAppender_WriteImageMessage;
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_PATH";
nSize = GetEnvironmentVariableA(name, NULL, 0);
if (nSize)
{
ZeroMemory(FileAppender, sizeof(wLogFileAppender));
env = (LPSTR) malloc(nSize);
if (!env)
goto error_free;
FileAppender->Type = WLOG_APPENDER_FILE;
nSize = GetEnvironmentVariableA(name, env, nSize);
status = WLog_FileAppender_SetOutputFilePath(log, FileAppender, env);
free(env);
FileAppender->Open = (WLOG_APPENDER_OPEN_FN) WLog_FileAppender_Open;
FileAppender->Close = (WLOG_APPENDER_OPEN_FN) WLog_FileAppender_Close;
if (!status)
goto error_free;
}
FileAppender->WriteMessage =
(WLOG_APPENDER_WRITE_MESSAGE_FN) WLog_FileAppender_WriteMessage;
FileAppender->WriteDataMessage =
(WLOG_APPENDER_WRITE_DATA_MESSAGE_FN) WLog_FileAppender_WriteDataMessage;
FileAppender->WriteImageMessage =
(WLOG_APPENDER_WRITE_IMAGE_MESSAGE_FN) WLog_FileAppender_WriteImageMessage;
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_NAME";
nSize = GetEnvironmentVariableA(name, NULL, 0);
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (!env)
goto error_output_file_name;
FileAppender->FileName = NULL;
FileAppender->FilePath = NULL;
FileAppender->FullFileName = NULL;
nSize = GetEnvironmentVariableA(name, env, nSize);
status = WLog_FileAppender_SetOutputFileName(log, FileAppender, env);
free(env);
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_PATH";
nSize = GetEnvironmentVariableA(name, NULL, 0);
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (env)
{
nSize = GetEnvironmentVariableA(name, env, nSize);
WLog_FileAppender_SetOutputFilePath(log, FileAppender, env);
free(env);
}
}
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_NAME";
nSize = GetEnvironmentVariableA(name, NULL, 0);
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (env)
{
nSize = GetEnvironmentVariableA(name, env, nSize);
WLog_FileAppender_SetOutputFileName(log, FileAppender, env);
free(env);
}
}
}
if (!status)
goto error_output_file_name;
}
return FileAppender;
error_output_file_name:
free(FileAppender->FilePath);
error_free:
free(FileAppender);
return NULL;
}
void WLog_FileAppender_Free(wLog* log, wLogFileAppender* appender)

View File

@ -359,39 +359,38 @@ wLogLayout* WLog_Layout_New(wLog* log)
wLogLayout* layout;
layout = (wLogLayout*) calloc(1, sizeof(wLogLayout));
if (!layout)
return NULL;
if (layout)
nSize = GetEnvironmentVariableA("WLOG_PREFIX", NULL, 0);
if (nSize)
{
nSize = GetEnvironmentVariableA("WLOG_PREFIX", NULL, 0);
if (nSize)
env = (LPSTR) malloc(nSize);
if (!env)
{
env = (LPSTR) malloc(nSize);
if (!env)
{
free(layout);
return NULL;
}
nSize = GetEnvironmentVariableA("WLOG_PREFIX", env, nSize);
free(layout);
return NULL;
}
nSize = GetEnvironmentVariableA("WLOG_PREFIX", env, nSize);
}
if (env)
layout->FormatString = env;
else
{
if (env)
layout->FormatString = env;
else
{
#ifdef ANDROID
layout->FormatString = _strdup("[pid=%pid:tid=%tid] - ");
layout->FormatString = _strdup("[pid=%pid:tid=%tid] - ");
#else
layout->FormatString = _strdup("[%hr:%mi:%se:%ml] [%pid:%tid] [%lv][%mn] - ");
layout->FormatString = _strdup("[%hr:%mi:%se:%ml] [%pid:%tid] [%lv][%mn] - ");
#endif
if (!layout->FormatString)
{
free(layout);
return NULL;
}
if (!layout->FormatString)
{
free(layout);
return NULL;
}
}
return layout;
}

View File

@ -80,7 +80,7 @@ void Pcap_Write_RecordContent(wPcap* pcap, wPcapRecord* record)
fwrite(record->data, record->length, 1, pcap->fp);
}
void Pcap_Read_Record(wPcap* pcap, wPcapRecord* record)
BOOL Pcap_Read_Record(wPcap* pcap, wPcapRecord* record)
{
if (pcap && pcap->fp)
{
@ -88,9 +88,10 @@ void Pcap_Read_Record(wPcap* pcap, wPcapRecord* record)
record->length = record->header.incl_len;
record->data = malloc(record->length);
if (!record->data)
return;
return FALSE;
fread(record->data, record->length, 1, pcap->fp);
}
return TRUE;
}
void Pcap_Write_Record(wPcap* pcap, wPcapRecord* record)
@ -168,8 +169,7 @@ BOOL Pcap_GetNext_Record(wPcap* pcap, wPcapRecord* record)
if (Pcap_HasNext_Record(pcap) != TRUE)
return FALSE;
Pcap_Read_Record(pcap, record);
return TRUE;
return Pcap_Read_Record(pcap, record);
}
wPcap* Pcap_Open(char* name, BOOL write)

View File

@ -552,8 +552,8 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
char* env = NULL;
DWORD nSize;
int iLevel;
log = (wLog*) calloc(1, sizeof(wLog));
log = (wLog*) calloc(1, sizeof(wLog));
if (!log)
return NULL;
@ -586,18 +586,21 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (env)
if (!env)
goto out_fail;
if (!GetEnvironmentVariableA("WLOG_LEVEL", env, nSize))
{
if (GetEnvironmentVariableA("WLOG_LEVEL", env, nSize))
{
iLevel = WLog_ParseLogLevel(env);
if (iLevel >= 0)
log->Level = (DWORD) iLevel;
}
fprintf(stderr, "WLOG_LEVEL environment variable changed in my back !\n");
free(env);
goto out_fail;
}
iLevel = WLog_ParseLogLevel(env);
free(env);
if (iLevel >= 0)
log->Level = (DWORD) iLevel;
}
}
@ -654,25 +657,36 @@ wLog* WLog_GetRoot()
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (env)
if (!env)
goto fail;
if (!GetEnvironmentVariableA("WLOG_APPENDER", env, nSize))
{
if (GetEnvironmentVariableA("WLOG_APPENDER", env, nSize))
{
if (_stricmp(env, "CONSOLE") == 0)
logAppenderType = WLOG_APPENDER_CONSOLE;
else if (_stricmp(env, "FILE") == 0)
logAppenderType = WLOG_APPENDER_FILE;
else if (_stricmp(env, "BINARY") == 0)
logAppenderType = WLOG_APPENDER_BINARY;
}
fprintf(stderr, "WLOG_APPENDER environment variable modified in my back");
free(env);
goto fail;
}
if (_stricmp(env, "CONSOLE") == 0)
logAppenderType = WLOG_APPENDER_CONSOLE;
else if (_stricmp(env, "FILE") == 0)
logAppenderType = WLOG_APPENDER_FILE;
else if (_stricmp(env, "BINARY") == 0)
logAppenderType = WLOG_APPENDER_BINARY;
free(env);
}
WLog_SetLogAppenderType(g_RootLog, logAppenderType);
if (!WLog_SetLogAppenderType(g_RootLog, logAppenderType))
goto fail;
}
return g_RootLog;
fail:
free(g_RootLog);
g_RootLog = NULL;
return NULL;
}
int WLog_AddChild(wLog* parent, wLog* child)
@ -747,9 +761,9 @@ wLog* WLog_Get(LPCSTR name)
return log;
}
void WLog_Init()
BOOL WLog_Init()
{
WLog_GetRoot();
return WLog_GetRoot() != NULL;
}
void WLog_Uninit()