Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Garbage Again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Warp <warplayer@f...>
Subject: [Caml-list] Garbage Again
It crashed again....
First, I'm allocating memory ( I think it's the good way to do it ) :
------------

 value *windata = malloc(sizeof(value));

 messageid = alloc(1,MSGID_TAG);
 Store_field(messageid,1,Val_int(0));

 handletag = alloc(1,HANDLE_TAG);
 Store_field(handletag,1,Val_int(0));

 message = alloc(5,MESSAGE_TAG);
 Store_field(message,0,handletag);
 Store_field(message,1,messageid);
 Store_field(message,2,Val_int(0)); // wParam
 Store_field(message,3,Val_int(0)); // lParam
 Store_field(message,4,Val_int(0)); // MSG*

 *windata = alloc(4,WINDOW_TAG);
 register_global_root(windata);
 Store_field(*windata,0,Val_unit);
 Store_field(*windata,1,callback);
 Store_field(*windata,2,message);
 Store_field(*windata,3,Val_int(func)); // default proc

---------
Then, creating the window, and linking custom data and handle

HWND handle = CreateWindow( .... )
// store handle into data
Store_field(*windata,0,Val_int(handle));
// store data into handle
SetWindowLong(handle,GWL_USERDATA,(long)windata);

--------
And my windowProc :
having parameters  ( hwnd, uMsg, wParam, lParam )

 windata = (value*)GetWindowLong(hwnd,GWL_USERDATA);
 callback = Field(*windata,1);

// update message fields
 message = Field(*windata,2);
 Store_field(Field(message,0),0,Val_int(hwnd));
 Store_field(Field(message,1),0,Val_int(uMsg));
 Store_field(message,2,Val_int(wParam));
 Store_field(message,3,Val_int(lParam));

// caml callback
 result = Int_val(callbackN_exn(callback,1,&message));
 return result;

---------
I got a crash in callbackN_exn / interprete / minor_collection /
empty_minor_head / oldify_local_root / .... (4 oldify calls) / *p = v
 minor_gc.c:122)

I can see that message is being collected, but I don't know why because
*windata contains it so....
I've tryed both with/without CAML* garbage macros, it doesn't work

Thanks for any help / clue.

Warp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr