Changeset 51 in libcf for trunk/src/cf_log.c
- Timestamp:
- 04/02/13 10:23:52 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cf_log.c
r50 r51 30 30 #define LOCK_LOG_CTX(__ctx) CF_Mutex_Lock (&__ctx->mutex) 31 31 #define UNLOCK_LOG_CTX(__ctx) CF_Mutex_Unlock (&__ctx->mutex) 32 #define CHECK_INITIALIZED() (gLogEnvironment.ctxPool == NULL|| \ 33 gLogEnvironment.ctxSize <= 0 ) 34 #define CHECK_INVALID_MAPID(__mapid) (gLogEnvironment.ctxSize <= __mapid) 35 #define CHECK_MAPPED_ID(__mapid) (gLogEnvironment.ctxPool[__mapid] != NULL) \ 36 32 #define CHECK_INITIALIZED() (gLogArray.ctxPool == NULL|| \ 33 gLogArray.ctxSize <= 0 ) 34 #define CHECK_INVALID_MAPID(__mapid) (gLogArray.ctxSize <= __mapid) 35 #define CHECK_MAPPED_ID(__mapid) (gLogArray.ctxPool[__mapid] != NULL) 37 36 38 37 #define LOG_BUFFER_DEFAULT_SIZE 128 * 1024 39 38 40 #define LOG_DATETIME_LENGTH sizeof ("0000-00-00 00:00:00.000") - 139 #define LOG_DATETIME_LENGTH sizeof ("0000-00-00 00:00:00.000") - 1 41 40 42 41 /** … … 69 68 } S_CF_LOG_CTX, CF_LOG_CTX; 70 69 71 typedef struct __cf_log_ environment__ {70 typedef struct __cf_log_array__ { 72 71 CF_Log_Ctx * ctxPool; 73 72 int ctxSize; 74 } S_CF_LOG_ ENVIRONMENT, CF_LOG_ENVIRONMENT;75 76 static CF_LOG_ ENVIRONMENT gLogEnvironment;73 } S_CF_LOG_ARRAY, CF_LOG_ARRAY; 74 75 static CF_LOG_ARRAY gLogArray; 77 76 78 77 #if defined(_WIN32) || defined(_WIN64) … … 475 474 } 476 475 477 gLog Environment.ctxPool[mapid] = ctx;476 gLogArray.ctxPool[mapid] = ctx; 478 477 479 478 return CF_OK; … … 501 500 return CF_ERROR_LOG_NOT_MAPPED_ID; 502 501 503 CF_Log_DestroyCtx (gLog Environment.ctxPool[mapid]);504 505 free (gLog Environment.ctxPool[mapid]);506 gLog Environment.ctxPool[mapid] = NULL;502 CF_Log_DestroyCtx (gLogArray.ctxPool[mapid]); 503 504 free (gLogArray.ctxPool[mapid]); 505 gLogArray.ctxPool[mapid] = NULL; 507 506 508 507 return CF_OK; … … 528 527 return CF_ERROR_LOG_NOT_MAPPED_ID; 529 528 530 *ctx = gLog Environment.ctxPool[mapid];529 *ctx = gLogArray.ctxPool[mapid]; 531 530 532 531 return CF_OK; … … 543 542 CF_Log_Initialize (const int logPool) 544 543 { 545 memset (&gLog Environment, 0x00, sizeof (CF_LOG_ENVIRONMENT));544 memset (&gLogArray, 0x00, sizeof (CF_LOG_ARRAY)); 546 545 547 546 if (logPool > 0) 548 547 { 549 gLog Environment.ctxPool =548 gLogArray.ctxPool = 550 549 (CF_Log_Ctx *) calloc ((size_t) logPool, sizeof (CF_Log_Ctx)); 551 if (gLog Environment.ctxPool == NULL)550 if (gLogArray.ctxPool == NULL) 552 551 return CF_ERROR_LOG_INITIALIZE; 553 gLog Environment.ctxSize = logPool;552 gLogArray.ctxSize = logPool; 554 553 } 555 554 … … 567 566 int mapid = 0; 568 567 569 for (mapid = 0 ; mapid < gLog Environment.ctxSize ; mapid++)568 for (mapid = 0 ; mapid < gLogArray.ctxSize ; mapid++) 570 569 { 571 570 CF_Log_UnmapCtxID (mapid); 572 571 } 573 572 574 if (gLog Environment.ctxPool != NULL)575 free (gLog Environment.ctxPool);576 577 memset (&gLog Environment, 0x00, sizeof (CF_LOG_ENVIRONMENT));573 if (gLogArray.ctxPool != NULL) 574 free (gLogArray.ctxPool); 575 576 memset (&gLogArray, 0x00, sizeof (CF_LOG_ARRAY)); 578 577 579 578 return CF_OK;
Note:
See TracChangeset
for help on using the changeset viewer.