[Core/Utils] Replace malloc() for logging
authorWook Song <wook16.song@samsung.com>
Fri, 23 Aug 2019 08:23:41 +0000 (17:23 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Tue, 27 Aug 2019 02:10:17 +0000 (11:10 +0900)
This patch replaces a malloc function for logging with char array.

Signed-off-by: Wook Song <wook16.song@samsung.com>
src/core/ne-utils.c

index 2db4ba3..022bbe0 100644 (file)
@@ -290,14 +290,10 @@ void logwrite(loglevel l, module m, const char *format, ...) {
   ltime = time(NULL);
 
   if (fp == NULL) {
-    size_t n = strlen(conf->log_dir) + strlen(logfilename);
-    char *filename = malloc(n + 1);
-
-    snprintf(filename, n, "%s%s", conf->log_dir, logfilename);
+    char filename[FILENAME_MAX];
 
+    snprintf(filename, FILENAME_MAX, "%s%s", conf->log_dir, logfilename);
     fp = fopen(filename, "a");
-
-    free (filename);
   }
 
   assert(fp != NULL);