1 | |
|
|
2 | /* |
1 | /* |
3 | * static char *rcsid_friend_c = |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
4 | * "$Id: links.C,v 1.2 2006/09/10 16:00:23 root 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 |
|
|
8 | * it under the terms of the GNU General Public License as published by |
|
|
9 | * the Free Software Foundation, either version 3 of the License, or |
|
|
10 | * (at your 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 GNU General Public License |
|
|
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
19 | * |
|
|
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
5 | */ |
21 | */ |
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 | |
22 | |
29 | #include <global.h> |
23 | #include <global.h> |
30 | |
24 | |
31 | /* |
25 | /* |
32 | * Allocates a new objectlink structure, initialises it, and returns |
26 | * Allocates a new objectlink structure, initialises it, and returns |
… | |
… | |
34 | */ |
28 | */ |
35 | |
29 | |
36 | objectlink * |
30 | objectlink * |
37 | get_objectlink (void) |
31 | get_objectlink (void) |
38 | { |
32 | { |
39 | objectlink *ol = (objectlink *) CALLOC (1, sizeof (objectlink)); |
33 | objectlink *ol = new objectlink; |
40 | |
34 | |
41 | ol->ob = NULL; |
35 | ol->ob = 0; |
42 | ol->next = NULL; |
36 | ol->next = 0; |
43 | ol->id = 0; |
|
|
44 | return ol; |
37 | return ol; |
45 | } |
38 | } |
46 | |
39 | |
47 | /* |
40 | /* |
48 | * Allocates a new oblinkpt structure, initialises it, and returns |
41 | * Allocates a new oblinkpt structure, initialises it, and returns |
… | |
… | |
50 | */ |
43 | */ |
51 | |
44 | |
52 | oblinkpt * |
45 | oblinkpt * |
53 | get_objectlinkpt (void) |
46 | get_objectlinkpt (void) |
54 | { |
47 | { |
55 | oblinkpt *obp = (oblinkpt *) malloc (sizeof (oblinkpt)); |
48 | oblinkpt *obp = new oblinkpt; |
56 | |
49 | |
57 | obp->link = NULL; |
50 | obp->link = 0; |
58 | obp->next = NULL; |
51 | obp->next = 0; |
59 | obp->value = 0; |
52 | obp->value = 0; |
60 | return obp; |
53 | return obp; |
61 | } |
54 | } |
62 | |
55 | |
63 | /* |
56 | /* |
… | |
… | |
67 | void |
60 | void |
68 | free_objectlink (objectlink * ol) |
61 | free_objectlink (objectlink * ol) |
69 | { |
62 | { |
70 | if (ol->next) |
63 | if (ol->next) |
71 | free_objectlink (ol->next); |
64 | free_objectlink (ol->next); |
72 | free (ol); |
65 | |
|
|
66 | delete ol; |
73 | } |
67 | } |
74 | |
68 | |
75 | /* |
69 | /* |
76 | * Recursively frees all linked list of objectlink pointers |
70 | * Recursively frees all linked list of objectlink pointers |
77 | */ |
71 | */ |
78 | |
72 | |
79 | void |
73 | void |
80 | free_objectlinkpt (oblinkpt * obp) |
74 | free_objectlinkpt (oblinkpt *obp) |
81 | { |
75 | { |
82 | if (obp->next) |
76 | if (obp->next) |
83 | free_objectlinkpt (obp->next); |
77 | free_objectlinkpt (obp->next); |
|
|
78 | |
84 | if (obp->link) |
79 | if (obp->link) |
85 | free_objectlink (obp->link); |
80 | free_objectlink (obp->link); |
86 | free (obp); |
81 | |
|
|
82 | delete obp; |
87 | } |
83 | } |