[Example] use an existed function rather than custom
authorHyoung Joo Ahn <hello.ahnn@gmail.com>
Fri, 18 Jan 2019 03:56:36 +0000 (12:56 +0900)
committerMyungJoo Ham <myungjoo.ham@gmail.com>
Sun, 20 Jan 2019 10:26:20 +0000 (19:26 +0900)
replace _strdup() to g_strdup() because it fulfills exactly same role

Signed-off-by: Hyoung Joo Ahn <hello.ahnn@gmail.com>
nnstreamer_example/custom_example_scaler/nnstreamer_customfilter_example_scaler.c
nnstreamer_example/custom_example_scaler/nnstreamer_customfilter_example_scaler_allocator.c

index d85d91a..2e2c334 100644 (file)
@@ -37,19 +37,6 @@ typedef struct _pt_data
 } pt_data;
 
 /**
- * @brief strdup() is not C89 compatible. Define it here.
- */
-static char *
-_strdup (const char *src)
-{
-  size_t len = strlen (src) + 1;
-  char *dest = (char *) malloc (sizeof (char) * len);
-  strncpy (dest, src, len - 1);
-  dest[len - 1] = '\0';
-  return dest;
-}
-
-/**
  * @brief tensor_filter_custom::NNS_custom_init_func
  */
 static void *
@@ -58,7 +45,7 @@ pt_init (const GstTensorFilterProperties * prop)
   pt_data *data = (pt_data *) malloc (sizeof (pt_data));
 
   if (prop->custom_properties && strlen (prop->custom_properties) > 0)
-    data->property = _strdup (prop->custom_properties);
+    data->property = g_strdup (prop->custom_properties);
   else
     data->property = NULL;
   data->new_x = 0;
index d40ed67..57962c0 100644 (file)
@@ -37,19 +37,6 @@ typedef struct _pt_data
 } pt_data;
 
 /**
- * @brief strdup replacement for C89 compliance
- */
-static char *
-_strdup (const char *src)
-{
-  size_t len = strlen (src) + 1;
-  char *dest = (char *) malloc (sizeof (char) * len);
-  strncpy (dest, src, len - 1);
-  dest[len - 1] = '\0';
-  return dest;
-}
-
-/**
  * @brief get data size of single tensor
  */
 static size_t
@@ -78,7 +65,7 @@ pt_init (const GstTensorFilterProperties * prop)
   pt_data *data = (pt_data *) malloc (sizeof (pt_data));
 
   if (prop->custom_properties && strlen (prop->custom_properties) > 0)
-    data->property = _strdup (prop->custom_properties);
+    data->property = g_strdup (prop->custom_properties);
   else
     data->property = NULL;
   data->new_x = 0;