[retro-gtk] retro-core: Support partially setting memory regions
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] retro-core: Support partially setting memory regions
- Date: Mon, 11 Sep 2017 14:50:39 +0000 (UTC)
commit e3f9193477bfa4a801d5a2602190ddba577e2464
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Sep 11 16:35:36 2017 +0200
retro-core: Support partially setting memory regions
When a memory region is set with less data than expected, fill the rest
with zeros instead of failing.
This helps supporting Libretro cores with fluctuating memory sizes.
https://bugzilla.gnome.org/show_bug.cgi?id=787548
retro-gtk/retro-core.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index e84d750..d925c85 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -1044,7 +1044,16 @@ retro_core_set_memory (RetroCore *self,
retro_core_pop_cb_data ();
g_return_if_fail (memory_region != NULL);
- g_return_if_fail (memory_region_size == length);
+ g_return_if_fail (memory_region_size >= length);
+
+ if (memory_region_size != length)
+ g_debug ("%s expects %"G_GSIZE_FORMAT" bytes for memory region %d: %d bytes"
+ " were passed. The excess will be filled with zeros.",
+ retro_core_get_name (self),
+ memory_region_size,
+ id,
+ length);
memcpy (memory_region, data, length);
+ memset (memory_region + length, 0, memory_region_size - length);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]