Due to memory management rules. See HACKING.
Signed-off-by: Tony Nguyen <tony.nguyen@bt.com>
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index fa2afcc..07a773e 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -767,7 +767,7 @@ static void utf8_string(void)
if (*end == ' ') {
end++;
}
- in = strndup(tail, end - tail);
+ in = g_strndup(tail, end - tail);
str = from_json_str(in, j, NULL);
g_assert(!str);
g_free(in);
diff --git a/tests/migration/stress.c b/tests/migration/stress.c
index 49a03aa..d9aa4af 100644
--- a/tests/migration/stress.c
+++ b/tests/migration/stress.c
@@ -104,9 +104,9 @@ static int get_command_arg_str(const char *name,
}
if (end)
- *val = strndup(start, end - start);
+ *val = g_strndup(start, end - start);
else
- *val = strdup(start);
+ *val = g_strdup(start);
return 1;
}
@@ -126,10 +126,10 @@ static int get_command_arg_ull(const char *name,
if (errno || *end) {
fprintf(stderr, "%s (%05d): ERROR: cannot parse %s value %s\n",
argv0, gettid(), name, valstr);
- free(valstr);
+ g_free(valstr);
return -1;
}
- free(valstr);
+ g_free(valstr);
return 0;
}
<tony.nguyen@bt.com> writes: > Due to memory management rules. See HACKING. > > Signed-off-by: Tony Nguyen <tony.nguyen@bt.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> I apologize for the delay.
Le 08/06/2019 à 07:25, tony.nguyen@bt.com a écrit :
> Due to memory management rules. See HACKING.
>
> Signed-off-by: Tony Nguyen <tony.nguyen@bt.com>
>
> diff --git a/tests/check-qjson.c b/tests/check-qjson.c
> index fa2afcc..07a773e 100644
> --- a/tests/check-qjson.c
> +++ b/tests/check-qjson.c
> @@ -767,7 +767,7 @@ static void utf8_string(void)
> if (*end == ' ') {
> end++;
> }
> - in = strndup(tail, end - tail);
> + in = g_strndup(tail, end - tail);
> str = from_json_str(in, j, NULL);
> g_assert(!str);
> g_free(in);
> diff --git a/tests/migration/stress.c b/tests/migration/stress.c
> index 49a03aa..d9aa4af 100644
> --- a/tests/migration/stress.c
> +++ b/tests/migration/stress.c
> @@ -104,9 +104,9 @@ static int get_command_arg_str(const char *name,
> }
>
> if (end)
> - *val = strndup(start, end - start);
> + *val = g_strndup(start, end - start);
> else
> - *val = strdup(start);
> + *val = g_strdup(start);
> return 1;
> }
>
> @@ -126,10 +126,10 @@ static int get_command_arg_ull(const char *name,
> if (errno || *end) {
> fprintf(stderr, "%s (%05d): ERROR: cannot parse %s value %s\n",
> argv0, gettid(), name, valstr);
> - free(valstr);
> + g_free(valstr);
> return -1;
> }
> - free(valstr);
> + g_free(valstr);
> return 0;
> }
>
Applied to my trivial-patches branch.
Thanks,
Laurent
© 2016 - 2026 Red Hat, Inc.