[Build Break Fix] C89 Compatibility issue in example
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 4 Jul 2018 02:45:32 +0000 (11:45 +0900)
committer오세원/Data Service Lab(SR)/Engineer/삼성전자 <sewon.oh@samsung.com>
Wed, 4 Jul 2018 04:19:39 +0000 (13:19 +0900)
The two then-pending PRs had been conflicting with each other.
This commit fixes the build break from them (C89 vs strtok_r)

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
nnstreamer_example/custom_example_scaler/nnstreamer_customfilter_example_scaler.c

index ad0932b..ea89201 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#include <glib.h>
 #include <tensor_filter_custom.h>
 
 typedef struct _pt_data
@@ -55,25 +56,23 @@ pt_init (const GstTensor_Filter_Properties * prop)
 
   /* Parse property and set new_x, new_y */
   if (data->property) {
-    const char s[6] = "Xx:_ ";
-    char *token;
-    char *saveptr;
-
-    token = strtok_r (data->property, s, &saveptr);
-
-    if (token != NULL) {
-      /* The first part */
-      data->new_x = atoi (token);
+    const char s[7] = "xX:_/ ";
+    gchar **strv = g_strsplit_set (data->property, s, 3);
+    if (strv[0] != NULL) {
+      data->new_x = (uint32_t) g_ascii_strtoll (strv[0], NULL, 10);
       if (data->new_x < 0)
         data->new_x = 0;
-      token = strtok_r (NULL, s, &saveptr);
-      if (token != NULL) {
-        /* The second part */
-        data->new_y = atoi (token);
-        if (data->new_y < 0)
-          data->new_y = 0;
-      }
+    } else {
+      data->new_x = 0;
+    }
+    if (strv[1] != NULL) {
+      data->new_y = (uint32_t) g_ascii_strtoll (strv[1], NULL, 10);
+      if (data->new_y < 0)
+        data->new_y = 0;
+    } else {
+      data->new_y = 0;
     }
+    g_strfreev (strv);
   }
 
   data->id = 0;