1 |
|
2 |
/* |
3 |
* static char *rcsid_friend_c = |
4 |
* "$Id: links.C,v 1.1 2006-08-13 17:16:00 elmex Exp $"; |
5 |
*/ |
6 |
|
7 |
/* |
8 |
CrossFire, A Multiplayer game for X-windows |
9 |
|
10 |
Copyright (C) 1992 Frank Tore Johansen |
11 |
|
12 |
This program is free software; you can redistribute it and/or modify |
13 |
it under the terms of the GNU General Public License as published by |
14 |
the Free Software Foundation; either version 2 of the License, or |
15 |
(at your option) any later version. |
16 |
|
17 |
This program is distributed in the hope that it will be useful, |
18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 |
GNU General Public License for more details. |
21 |
|
22 |
You should have received a copy of the GNU General Public License |
23 |
along with this program; if not, write to the Free Software |
24 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 |
|
26 |
The author can be reached via e-mail to frankj@ifi.uio.no. |
27 |
*/ |
28 |
|
29 |
#include <global.h> |
30 |
|
31 |
/* |
32 |
* Allocates a new objectlink structure, initialises it, and returns |
33 |
* a pointer to it. |
34 |
*/ |
35 |
|
36 |
objectlink * |
37 |
get_objectlink (void) |
38 |
{ |
39 |
objectlink *ol = (objectlink *) CALLOC (1, sizeof (objectlink)); |
40 |
|
41 |
ol->ob = NULL; |
42 |
ol->next = NULL; |
43 |
ol->id = 0; |
44 |
return ol; |
45 |
} |
46 |
|
47 |
/* |
48 |
* Allocates a new oblinkpt structure, initialises it, and returns |
49 |
* a pointer to it. |
50 |
*/ |
51 |
|
52 |
oblinkpt * |
53 |
get_objectlinkpt (void) |
54 |
{ |
55 |
oblinkpt *obp = (oblinkpt *) malloc (sizeof (oblinkpt)); |
56 |
|
57 |
obp->link = NULL; |
58 |
obp->next = NULL; |
59 |
obp->value = 0; |
60 |
return obp; |
61 |
} |
62 |
|
63 |
/* |
64 |
* Recursively frees all objectlinks |
65 |
*/ |
66 |
|
67 |
void |
68 |
free_objectlink (objectlink * ol) |
69 |
{ |
70 |
if (ol->next) |
71 |
free_objectlink (ol->next); |
72 |
free (ol); |
73 |
} |
74 |
|
75 |
/* |
76 |
* Recursively frees all linked list of objectlink pointers |
77 |
*/ |
78 |
|
79 |
void |
80 |
free_objectlinkpt (oblinkpt * obp) |
81 |
{ |
82 |
if (obp->next) |
83 |
free_objectlinkpt (obp->next); |
84 |
if (obp->link) |
85 |
free_objectlink (obp->link); |
86 |
free (obp); |
87 |
} |