From 61fd7bbeb631550f31f39542235a3ebc9e68312a Mon Sep 17 00:00:00 2001
From: Lars Kanis <kanis@comcard.de>
Date: Tue, 7 Feb 2012 17:12:58 +0100
Subject: [PATCH] Add assertion for overwriting entries in FXRuby_Objects
table.
---
ext/fox16/FXRuby.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ext/fox16/FXRuby.cpp b/ext/fox16/FXRuby.cpp
index ad7feb0..a637441 100644
--- a/ext/fox16/FXRuby.cpp
+++ b/ext/fox16/FXRuby.cpp
@@ -112,10 +112,12 @@ VALUE FXRbNewPointerObj(void *ptr,swig_type_info* ty){
FXRubyObjDesc *desc;
if(FXMALLOC(&desc,FXRubyObjDesc,1)){
obj=SWIG_Ruby_NewPointerObj(ptr,ty,1);
+ FXTRACE((1,"FXRbNewPointerObj(rubyObj=%d,foxObj=%p)\n",static_cast<int>(obj),ptr));
desc->obj=obj;
desc->borrowed=true;
desc->in_gc=false;
- st_insert(FXRuby_Objects,reinterpret_cast<st_data_t>(ptr),reinterpret_cast<st_data_t>(desc));
+ int overwritten = st_insert(FXRuby_Objects,reinterpret_cast<st_data_t>(ptr),reinterpret_cast<st_data_t>(desc));
+ FXASSERT(!overwritten);
return obj;
}
else{
@@ -236,7 +238,8 @@ void FXRbRegisterRubyObj(VALUE rubyObj,const void* foxObj) {
desc->obj=rubyObj;
desc->borrowed=false;
desc->in_gc=false;
- st_insert(FXRuby_Objects,reinterpret_cast<st_data_t>(const_cast<void*>(foxObj)),reinterpret_cast<st_data_t>(desc));
+ int overwritten = st_insert(FXRuby_Objects,reinterpret_cast<st_data_t>(const_cast<void*>(foxObj)),reinterpret_cast<st_data_t>(desc));
+ FXASSERT(!overwritten);
}
else{
FXASSERT(FALSE);
--
GitLab