Re: [glib] malloc and bdwgc
- From: 张海 <dreaming in code zh gmail com>
- To: Ben Iofel <iofelben gmail com>
- Cc: gtk-devel-list gnome org
- Subject: Re: [glib] malloc and bdwgc
- Date: Thu, 7 Jan 2016 19:05:58 +0800
Yes it should be able to intercept the call, but it feels much too
hacky because I'll always need a wrapper exectuable for that, or my
binray won't work correctly. Just also came across this,
http://stackoverflow.com/questions/262439/create-a-wrapper-function-for-malloc-and-free-in-c
. It says I can define a custom wrapper malloc and free, then use
dlsym for the original ones. Sounds a bit cleaner.
However in both cases, I cannot think of a way to make GC_malloc() to
call the original malloc without my hook.
--
张海
浙江大学 计算机科学与技术
Blog: http://blog.zhanghai.me/
Github: https://github.com/DreaminginCodeZH
2016-01-07 18:13 GMT+08:00 Ben Iofel <iofelben gmail com>:
Can you use LD_PRELOAD to hook into malloc?
On Thu, Jan 7, 2016, 2:10 AM 张海 <dreaming in code zh gmail com> wrote:
I'm using glib without the whole GObject system and reference counting
mechanism, and I'd like to integrate bdwgc
(https://github.com/ivmai/bdwgc/) because of the complexity of my
program.
I've read about using GMemVTable to redirect memory allocation of glib
to GC_malloc, however as in
https://mail.gnome.org/archives/commits-list/2015-July/msg05892.html ,
such mechanism no longer works, and even more unfortunately it says
glib allocates memory before main() so it seems that I'm even unable
to hook to malloc in time as in
http://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html
.
Can I use bdwgc with glib >= 2.4.6? If so, how can I achieve that
correctly?
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]