1 | /* |
1 | /* |
2 | * object.C: Object management. |
2 | * object.C: Object management. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
4 | * |
4 | * |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
6 | */ |
6 | */ |
7 | |
7 | |
8 | static char const rcsid[] = "$Id: object.C,v 1.3 2007/07/21 13:23:22 pippijn Exp $"; |
8 | static char const rcsid[] = "$Id: object.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; |
9 | |
9 | |
10 | #include "atheme.h" |
10 | #include "atheme.h" |
11 | |
11 | |
12 | /* |
12 | /* |
13 | * object_init |
13 | * object_init |
… | |
… | |
28 | void |
28 | void |
29 | object_init (object_t * obj, const char *name, destructor_t des) |
29 | object_init (object_t * obj, const char *name, destructor_t des) |
30 | { |
30 | { |
31 | return_if_fail (obj != NULL); |
31 | return_if_fail (obj != NULL); |
32 | |
32 | |
33 | // if (name != NULL) |
33 | if (name != NULL) |
34 | // obj->name = sstrdup (name); |
34 | obj->name = sstrdup (name); |
|
|
35 | else |
|
|
36 | obj->name = sstrdup (""); |
35 | |
37 | |
36 | obj->destructor = des; |
38 | obj->destructor = des; |
37 | obj->refcount = 1; |
39 | obj->refcount = 1; |
38 | } |
40 | } |
39 | |
41 | |
… | |
… | |
85 | |
87 | |
86 | obj->refcount--; |
88 | obj->refcount--; |
87 | |
89 | |
88 | if (obj->refcount <= 0) |
90 | if (obj->refcount <= 0) |
89 | { |
91 | { |
90 | if (obj->name != NULL) |
|
|
91 | free (obj->name); |
92 | sfree (obj->name); |
92 | |
93 | |
93 | if (obj->destructor != NULL) |
94 | if (obj->destructor != NULL) |
94 | obj->destructor (obj); |
95 | obj->destructor (obj); |
95 | else |
96 | else |
96 | free (obj); |
97 | sfree (obj); |
97 | } |
98 | } |
98 | } |
99 | } |
99 | |
|
|
100 | /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs |
|
|
101 | * vim:ts=8 |
|
|
102 | * vim:sw=8 |
|
|
103 | * vim:noexpandtab |
|
|
104 | */ |
|
|