[REBOL] DLL questions
From: robert:muench:robertmuench at: 10-Jan-2004 13:41
Hi, some more strange problmes. Here is my Rebol code snippet:
graphit-lib: load/library %graphit.dll
new-storage: make routine! [
"Create new storage"
storage [string!] "Name of storage file"
return: [integer!]
] graphit-lib "new_storage"
close-storage: make routine! [
dummy [integer!]
] graphit-lib "close_storage"
get-block: make routine! [
name [string!]
] graphit-lib "get_block"
; close-storage 1
print new-storage "rebol-test.db"
get-block "test"
; close-storage 1
free graphit-lib
halt
And here the C code for the DLL graphit.dll Note: It's just test code,
don't look at the function names.
#include "e4graph.h"
char *test;
extern "C" {
long _export new_storage(char* name) {
e4_Storage storage("test", E4_METAKIT);
// get Root node so that we have a place to start from
e4_Node root;
if(!storage.GetRootNode(root)) {
return false;
}
return true;
}
void _export close_storage(int a) {
test = new char(200);
return;
}
void _export get_block(char* name) {
return;
}
}
As soon as I call "close_storage" from my Rebol script it hangs. I really
don't know where the problem comes from. I know it has something to do
with the case, when I try to do anything WRT memory operations. Adding a
static global, allocating memory etc. than Rebol hangs.
--
Robert M. Münch
Management & IT Freelancer
Mobile: +49 (177) 245 2802
http://www.robertmuench.de<