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