[glib] Revert "Cleanups after we dropped mem vtables"
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Revert "Cleanups after we dropped mem vtables"
- Date: Sat, 12 Sep 2015 16:06:15 +0000 (UTC)
commit b9a27679ec1555262c0c721ec1793d7acd7766d9
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 12 12:05:31 2015 -0400
Revert "Cleanups after we dropped mem vtables"
This reverts commit 627854fee1fde93e01f27655b00a9082348ee15f.
It has been argued that not aborting on malloc() failure is
an incompatible change.
glib/gstrfuncs.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index a251631..dde6126 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -354,10 +354,19 @@ get_C_locale (void)
gchar*
g_strdup (const gchar *str)
{
+ gchar *new_str;
+ gsize length;
+
if (str)
- return strdup (str);
+ {
+ length = strlen (str) + 1;
+ new_str = g_new (char, length);
+ memcpy (new_str, str, length);
+ }
else
- return NULL;
+ new_str = NULL;
+
+ return new_str;
}
/**
@@ -409,10 +418,18 @@ gchar*
g_strndup (const gchar *str,
gsize n)
{
+ gchar *new_str;
+
if (str)
- return strndup (str, n);
+ {
+ new_str = g_new (gchar, n + 1);
+ strncpy (new_str, str, n);
+ new_str[n] = '\0';
+ }
else
- return NULL;
+ new_str = NULL;
+
+ return new_str;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]