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