[goffice] Compilation: don't use g_memdup.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Compilation: don't use g_memdup.
- Date: Thu, 2 Dec 2021 02:36:04 +0000 (UTC)
commit bd8810cd6a1ffd7a23a2077b5af624479b3458ef
Author: Morten Welinder <terra gnome org>
Date: Wed Dec 1 21:35:35 2021 -0500
Compilation: don't use g_memdup.
Dead kittens ohoy!
ChangeLog | 5 +++++
NEWS | 1 +
goffice/math/go-complex.c | 2 +-
goffice/math/go-quad.c | 2 +-
goffice/utils/go-glib-extras.c | 21 +++++++++++++++++++++
goffice/utils/go-glib-extras.h | 2 ++
goffice/utils/go-line.c | 2 +-
goffice/utils/go-pixbuf.c | 2 +-
8 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e7e5ae3d..84de7864 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-12-01 Morten Welinder <terra gnome org>
+
+ * goffice/utils/go-glib-extras.c (go_memdup): Replacement for
+ g_memdup until we depend on glib 2.67 or thereabouts.
+
2021-11-06 Morten Welinder <terra gnome org>
* goffice/math/go-math.c (go_pow10): Make a much bigger table to
diff --git a/NEWS b/NEWS
index 0a774e8f..913edaad 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ John Denker:
Morten:
* Introspection updates.
* Improve go_pow10 accuracy by avoiding pow as much as possible.
+ * Take evasive action re g_memdup.
--------------------------------------------------------------------------
goffice 0.10.50:
diff --git a/goffice/math/go-complex.c b/goffice/math/go-complex.c
index 6375f119..1066a0a1 100644
--- a/goffice/math/go-complex.c
+++ b/goffice/math/go-complex.c
@@ -62,7 +62,7 @@
static COMPLEX *
SUFFIX(go_complex_dup) (COMPLEX *src)
{
- return g_memdup (src, sizeof (*src));
+ return go_memdup (src, sizeof (*src));
}
#define MAKE_BOXED_TYPE(id,name) \
diff --git a/goffice/math/go-quad.c b/goffice/math/go-quad.c
index bb77f57a..98b973ea 100644
--- a/goffice/math/go-quad.c
+++ b/goffice/math/go-quad.c
@@ -202,7 +202,7 @@ SUFFIX(go_quad_start) (void)
_FPU_EXTENDED | _FPU_DOUBLE | _FPU_SINGLE;
_FPU_GETCW (state);
- res = g_memdup (&state, sizeof (state));
+ res = go_memdup (&state, sizeof (state));
newstate = (state & ~mask) | _FPU_DOUBLE;
_FPU_SETCW (newstate);
diff --git a/goffice/utils/go-glib-extras.c b/goffice/utils/go-glib-extras.c
index bb1da232..1a2b54df 100644
--- a/goffice/utils/go-glib-extras.c
+++ b/goffice/utils/go-glib-extras.c
@@ -854,6 +854,27 @@ go_destroy_password (char *passwd)
}
+/**
+ * go_memdup:
+ * @mem: (nullable): Memory to copy
+ * @byte_size: size of memory block to copy
+ *
+ * Like g_memdup or g_memdup2. This function is meant to easy transition
+ * to g_memdup2 without having to require very new glib.
+ **/
+gpointer
+go_memdup (gconstpointer mem, gsize byte_size)
+{
+ if (mem && byte_size != 0) {
+ gpointer new_mem = g_malloc (byte_size);
+ memcpy (new_mem, mem, byte_size);
+ return new_mem;
+ } else
+ return NULL;
+}
+
+
+
/**
* go_object_toggle:
* @object: #GObject
diff --git a/goffice/utils/go-glib-extras.h b/goffice/utils/go-glib-extras.h
index a9b67f97..4424474e 100644
--- a/goffice/utils/go-glib-extras.h
+++ b/goffice/utils/go-glib-extras.h
@@ -89,6 +89,8 @@ char const *go_guess_encoding (char const *raw, gsize len,
char const *go_get_real_name (void);
void go_destroy_password (char *passwd);
+gpointer go_memdup (gconstpointer mem, gsize byte_size);
+
GType go_mem_chunk_get_type (void);
GOMemChunk *go_mem_chunk_new (char const *name, gsize user_atom_size, gsize chunk_size);
void go_mem_chunk_destroy (GOMemChunk *chunk, gboolean expect_leaks);
diff --git a/goffice/utils/go-line.c b/goffice/utils/go-line.c
index cc99dc11..e215c63f 100644
--- a/goffice/utils/go-line.c
+++ b/goffice/utils/go-line.c
@@ -507,7 +507,7 @@ go_arrow_init_oval (GOArrow *dst, double ra, double rb)
GOArrow *
go_arrow_dup (GOArrow *src)
{
- return g_memdup (src, sizeof (*src));
+ return go_memdup (src, sizeof (*src));
}
gboolean
diff --git a/goffice/utils/go-pixbuf.c b/goffice/utils/go-pixbuf.c
index 97716795..e9ca1ffc 100644
--- a/goffice/utils/go-pixbuf.c
+++ b/goffice/utils/go-pixbuf.c
@@ -394,7 +394,7 @@ go_pixbuf_new_from_data (char const *type, guint8 const *data, gsize length, GEr
if (!error)
error = &dummy;
- image->data = g_memdup (data, length);
+ image->data = go_memdup (data, length);
image->data_length = length;
g_object_set (image, "image-type", type, NULL);
go_pixbuf_create_pixbuf (GO_PIXBUF (image), error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]