Re: gobjects, glists and arrays beginners question
- From: Pavel Syomin <syomin radico ru>
- To: Mathias Andre <mathias acronycal org>, "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Cc:
- Subject: Re: gobjects, glists and arrays beginners question
- Date: Thu, 26 May 2005 14:53:01 +0400
Hi!
I think, that better way is (this is example only) :
typedef struct _Machine Machine;
struct _Machine {
gint machine_number;
gchar *machine_name;
gchar *model;
gchar *operator;
/* ... */
};
Machine *machine_new(gint machine_number,
const gchar *machine_name,
const gchar *model,
const gchar *operator)
{
Machine *machine;
g_return_val_if_fail(machine_number > 0, NULL);
g_return_val_if_fail(machine_name != NULL, NULL);
g_return_val_if_fail(model != NULL, NULL);
g_return_val_if_fail(operator != NULL, NULL);
machine = g_new(Machine, 1);
machine->machine_number = machine_number;
machine->machine_name = g_strdup(machine_name);
machine->model = g_strdup(model);
machine->operator = g_strdup(operator);
/* ... */
return machine;
}
void machine_free(Machine *machine)
{
g_return_if_fail(machine != NULL);
/* ... */
g_free(machine->machine_name);
g_free(machine->model);
g_free(machine->operator);
g_free(machine);
}
For store Machine's you can use one of GLib containers.
Mathias Andre wrote:
Hi Kim,
You can find a really complete GObjects tutorial at
http://www.le-hacker.org/papers/gobject/
If you don't really know where to start have a look at the boilerplate
gobject code in this tutorial.
Good luck,
Mathias
------------------------------------------------------------------------
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]