Re: error in passing a structure in argument of a CallBack function
- From: Jonathan Irwin <jmi25 cam ac uk>
- To: D Reymond <reymond d labogeo pf>
- Cc: gtk_devel_list <gtk-app-devel-list gnome org>
- Subject: Re: error in passing a structure in argument of a CallBack function
- Date: Sun, 6 May 2001 09:34:07 +0100 (BST)
On Sat, 5 May 2001, D Reymond wrote:
<...>
void function_1(void)
{
..........
struct stab psTab;
This should be 'struct stab *psTab' to declare a pointer to the struct
psTab = (struct stab *)g_malloc(sizeof(struct stab *));
The parameter to g_malloc() should be 'sizeof(struct stab)', so it
allocates enough memory for the struct (rather than just a pointer to it).
if ( psTab == NULL ) { printf(" pb to alloc struct \n"); exit(-1); }
The checks for NULL are not necessary for g_malloc() and friends because
they will bomb for you on error.
Hope this helps
Jonathan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]