Skip to content

Commit

Permalink
use constant size for time_c array
Browse files Browse the repository at this point in the history
  • Loading branch information
aharren committed Nov 1, 2013
1 parent e9f5767 commit 7df083a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions LCLLogFile.m
Expand Up @@ -437,9 +437,9 @@ static void _LCLLogFile_log(const char *identifier_c, uint32_t level,
const char *message_c = [message UTF8String];

// get size of log entry
const int time_c_len = 24;
char time_c[24];
const int backslash_n_len = 1;
size_t entry_len = time_c_len + strlen(prefix_c) + strlen(message_c) + backslash_n_len;
size_t entry_len = sizeof(time_c) + strlen(prefix_c) + strlen(message_c) + backslash_n_len;

// under lock protection ...
[_LCLLogFile_lock lock];
Expand All @@ -458,7 +458,6 @@ static void _LCLLogFile_log(const char *identifier_c, uint32_t level,
// get current time
struct timeval now;
struct tm now_tm;
char time_c[time_c_len];
gettimeofday(&now, NULL);
localtime_r(&now.tv_sec, &now_tm);
snprintf(time_c, sizeof(time_c), "%04d-%02d-%02d %02d:%02d:%02d.%03d",
Expand Down

0 comments on commit 7df083a

Please sign in to comment.