1 /* DLIFE Copyright (C) 2000 Richard W.M. Jones <rich@annexia.org>
2 * and other authors listed in the ``AUTHORS'' file.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * $Id: state.c,v 1.2 2002/04/05 16:47:13 rich Exp $
31 state_malloc (int _soup_size, int thread_num)
33 struct state *p = malloc (sizeof (struct state));
34 if (p == 0) { perror ("malloc"); abort (); }
37 p->nr_cells_alive = 0;
38 p->nr_cells_allocated = 0;
39 dlink_list_init (&p->alive_list, offsetof (struct cell, next));
40 dlink_list_init (&p->best_list, offsetof (struct cell, worse));
41 soup_init (p, _soup_size);
43 p->thread_num = thread_num;
49 state_free (struct state *state)
53 /* Free up cells. This also cleans up soup frags. */
54 for (p = (struct cell *) state->alive_list.first; p; p = p->next)
62 /* Free up soup image filename. */
63 if (state->filename) free (state->filename);
65 /* Free up structure. */