g_object_new shared memory

2009-10-26 Thread Hieu Le Trung
Hi,

I'm using GLib in my application, and I'm using g_object_new to allocate
memory of an object. As in C++ specification, there is new placement
technique that can allow us to place a new object into our predefined
memory region. And we can also do with malloc by redefine the malloc
fuction.

I wonder if we can do it with g_object_new or not? The purpose is to
have g_object_new to allocate memory on my own memory region.

Thanks,
-Hieu

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_object_new shared memory

2009-10-26 Thread David Nečas
On Mon, Oct 26, 2009 at 05:09:42PM +0700, Hieu Le Trung wrote:
 I'm using GLib in my application, and I'm using g_object_new to allocate
 memory of an object. As in C++ specification, there is new placement
 technique that can allow us to place a new object into our predefined
 memory region. And we can also do with malloc by redefine the malloc
 fuction.
 
 I wonder if we can do it with g_object_new or not? The purpose is to
 have g_object_new to allocate memory on my own memory region.

I don't think it's possible because g_type_create_instance() has the
allocation function hardcoded (g_slice_alloc0() at this moment).

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


RE: g_object_new shared memory

2009-10-26 Thread Hieu Le Trung
On Monday, October 26, 2009 5:22 PM, David Nečas wrote:
 On Mon, Oct 26, 2009 at 05:09:42PM +0700, Hieu Le Trung wrote:
  I wonder if we can do it with g_object_new or not? The purpose is to
  have g_object_new to allocate memory on my own memory region.
 
 I don't think it's possible because g_type_create_instance() has the
 allocation function hardcoded (g_slice_alloc0() at this moment).

Can I change the g_slide_alloc0 to use my own alloc function so that it can be 
allocated in a shared region?
Or can I override the constructor of my class so that the private data is 
allocated in a shared region, then in other application, I'll reconstruct the 
object using g_object_new and then set the private data pointer manually?

Regards,
-Hieu
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list