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,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
|
|
5 | * Copyright (©) 1992 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> |
5 | */ |
22 | */ |
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 | |
23 | |
29 | #include <global.h> |
24 | #include <global.h> |
30 | |
25 | |
31 | /* |
26 | /* |
32 | * Allocates a new objectlink structure, initialises it, and returns |
27 | * Allocates a new objectlink structure, initialises it, and returns |
33 | * a pointer to it. |
28 | * a pointer to it. |
34 | */ |
29 | */ |
35 | |
30 | |
36 | objectlink * |
31 | objectlink * |
37 | get_objectlink (void) |
32 | get_objectlink () |
38 | { |
33 | { |
39 | objectlink *ol = (objectlink *) CALLOC (1, sizeof (objectlink)); |
34 | objectlink *ol = new objectlink; |
40 | |
35 | |
41 | ol->ob = NULL; |
36 | ol->ob = 0; |
42 | ol->next = NULL; |
37 | ol->next = 0; |
43 | ol->id = 0; |
38 | |
44 | return ol; |
39 | return ol; |
45 | } |
40 | } |
46 | |
41 | |
47 | /* |
42 | /* |
48 | * Allocates a new oblinkpt structure, initialises it, and returns |
43 | * Allocates a new oblinkpt structure, initialises it, and returns |
49 | * a pointer to it. |
44 | * a pointer to it. |
50 | */ |
45 | */ |
51 | |
46 | |
52 | oblinkpt * |
47 | oblinkpt * |
53 | get_objectlinkpt (void) |
48 | get_objectlinkpt () |
54 | { |
49 | { |
55 | oblinkpt *obp = (oblinkpt *) malloc (sizeof (oblinkpt)); |
50 | oblinkpt *obp = new oblinkpt; |
56 | |
51 | |
57 | obp->link = NULL; |
52 | obp->link = 0; |
58 | obp->next = NULL; |
53 | obp->next = 0; |
59 | obp->value = 0; |
54 | |
60 | return obp; |
55 | return obp; |
61 | } |
56 | } |
62 | |
57 | |
63 | /* |
58 | /* |
64 | * Recursively frees all objectlinks |
59 | * Recursively frees all objectlinks |
65 | */ |
60 | */ |
66 | |
61 | |
67 | void |
62 | void |
68 | free_objectlink (objectlink * ol) |
63 | free_objectlink (objectlink *ol) |
69 | { |
64 | { |
70 | if (ol->next) |
65 | if (ol->next) |
71 | free_objectlink (ol->next); |
66 | free_objectlink (ol->next); |
72 | free (ol); |
67 | |
|
|
68 | delete ol; |
73 | } |
69 | } |
74 | |
70 | |
75 | /* |
71 | /* |
76 | * Recursively frees all linked list of objectlink pointers |
72 | * Recursively frees all linked list of objectlink pointers |
77 | */ |
73 | */ |
78 | |
74 | |
79 | void |
75 | void |
80 | free_objectlinkpt (oblinkpt * obp) |
76 | free_objectlinkpt (oblinkpt *obp) |
81 | { |
77 | { |
82 | if (obp->next) |
78 | if (obp->next) |
83 | free_objectlinkpt (obp->next); |
79 | free_objectlinkpt (obp->next); |
|
|
80 | |
84 | if (obp->link) |
81 | if (obp->link) |
85 | free_objectlink (obp->link); |
82 | free_objectlink (obp->link); |
86 | free (obp); |
83 | |
|
|
84 | delete obp; |
87 | } |
85 | } |
|
|
86 | |