Re: [AD] load_datafile_object with properties

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 07 October 2002 07:56, Eric Botcazou wrote:
> What will this function be used for ?

The common cases of adding a member to a linked list, and destroying the 
linked list along with the object:

struct list {
  int a, b, c;
  struct list* next;
};

void add_to_list(struct list* l, int a, int b, int c)
{
  struct list* n = malloc(sizeof(struct list));
  memset(n, 0, sizeof(struct list));
  n->a = a;
  n->b = b;
  n->c = c;
  n->next = l->next;
  l->next = n;
}

void destroy_list(struct list* l)
{
  struct list* n = 0;
  for(; l; l = n) {
    n = l->next;
    free(l);
  }
}

These two functions would be used as helpers by the datafile loading and 
unloading code, and are the main helpers for when you want to alter an 
object's properties. Of course, by making the linked list public, 
people can also do other stuff such as removing certain elements, etc.

Bye for now,
- -- 
Laurence Withers,  lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQE9oVuvUdhclgSmRuoRAi1kAJ48RpbBo4jFQf0pkOfUufAqPHrPGgCfYh6p
mq9C5Ic6FirJBPWfFymw2To=
=J0yJ
-----END PGP SIGNATURE-----



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/