Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / oc_logger / c / oc_logger.c
index 7b2db2b..77df219 100644 (file)
@@ -19,6 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "oc_logger.h"
+#include "oic_string.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -149,7 +150,6 @@ size_t oc_log_write_level(oc_log_ctx_t *ctx, const oc_log_level loglevel, const
 int oc_log_set_module(oc_log_ctx_t *ctx, const char *module_name)
 {
  char *mn = NULL;
- size_t len = 0;
 
  if(!ctx || !module_name)
  {
@@ -157,17 +157,13 @@ int oc_log_set_module(oc_log_ctx_t *ctx, const char *module_name)
  }
 
  /* Swap pointers so that module data's not erased in the event of failure: */
- len = strlen(module_name);
-
- mn = (char *)malloc(1 + len);
+ mn = OICStrdup(module_name);
 
  if(!mn)
  {
      return 0;
  }
 
- memcpy(mn, module_name, 1 + len);
-
  if(!ctx->module_name)
  {
      free(ctx->module_name);