25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
|
*/
#include <stdlib.h>
#include "cfwobject.h"
void*
cfw_new(CFWClass *class)
cfw_new(CFWClass *class, ...)
{
CFWObject *obj;
if ((obj = malloc(class->size)) == NULL)
return NULL;
obj->clsptr = class;
obj->ref_cnt = 1;
if (class->ctor != NULL)
class->ctor(obj);
if (class->ctor != NULL) {
va_list args;
va_start(args, class);
if (!class->ctor(obj, args)) {
cfw_unref(obj);
return NULL;
}
va_end(args);
}
return obj;
}
void*
cfw_ref(void *ptr)
{
|