Re: Calling a module with a gpointer to data.
- From: Tristan Van Berkom <vantr touchtunes com>
- To: hopeye cfl rr com
- Cc: Harring Figueiredo <harringf yahoo com>, GTK+ mailing list <gtk-app-devel-list gnome org>
- Subject: Re: Calling a module with a gpointer to data.
- Date: Wed, 31 Jul 2002 10:34:44 -0400
void func(void) {
int var = 0; // var is on the stack and will dissapear after the scope
of "func"
int *pvar = NULL;
if ((pvar = malloc(sizeof(int))) == NULL) {
/* bla bla */
}
*pvar = var; // pvar points to memory allocated on the "heap" and will
not dissapear after "func"
}
Cheers
Jim Parker wrote:
Ok here is the code.
I did not understand your comment about the stack versus the heap.
Thanks for your help
cheers
Jim Parker
On Mon, 29 Jul 2002, Harring Figueiredo wrote:
Date: Mon, 29 Jul 2002 20:56:12 -0700 (PDT)
To: hopeye cfl rr com, GTK+ mailing list <gtk-app-devel-list gnome org>
From: Harring Figueiredo <harringf yahoo com>
Sender: gtk-app-devel-list-admin gnome org
Subject: Re: Calling a module with a gpointer to data.
Could you provide the code ?
It seems - from the description -that you are passing a "string" greated
on
the stack, and not on the heap.
Harring
--- Jim Parker <hopeye cfl rr com> wrote:
G'Day !
My application uses plug-ins to extend the functionality. When I load
a
plug-in I build a menu structure in the normal way. But when I attach
a
callback to the menu. The data pointer seems to be corrupt.
Currently I am just passing a text string. But when I call the
function it
does not print properly (garbage characters). It works great for the
menu
items that were created in the main program.
Do I need to do something differently ?
cheers,
Jim Parker
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
------------------------------------------------------------------------
Name: plugin.tar.gz
plugin.tar.gz Type: Unix Tape Archive (application/x-tar)
Encoding: base64
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]