taskrambler  0.1.9
Web server and task management solution.
i_class.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include "class/class.h"
#include "class/interface/class.h"
#include "utils/memory.h"
+ Include dependency graph for i_class.c:

Go to the source code of this file.

Functions

void * classNewParams (class_ptr class, va_list *params)
 
void * classNew (class_ptr class,...)
 
void classDelete (void **object)
 
void * classClone (void *_object)
 

Variables

const struct interface i_Class
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file i_class.c.

Function Documentation

void* classClone ( void *  _object)

Definition at line 85 of file i_class.c.

References CALL, clone, memCalloc(), and class_ptr::object_size.

86 {
87  class_ptr class = GET_CLASS(_object);
88  void * object = memCalloc(1, class->object_size + sizeof(void*));
89 
90  * (class_ptr *)object = class;
91  object += sizeof(void*);
92 
93 #undef clone
94  CALL(object, Class, clone, _object);
95 
96  return object;
97 }
#define CALL(object, _iface, method,...)
Definition: class/class.h:106
#define clone(object)
void * memCalloc(size_t, size_t)
Definition: memory.c:818
size_t object_size
Definition: class/class.h:136

+ Here is the call graph for this function:

void classDelete ( void **  object)

Definition at line 71 of file i_class.c.

References CALL, and MEM_FREE.

Referenced by classNewParams().

72 {
73  if (NULL != *object) {
74  void * mem;
75 
76  CALL(*object, Class, dtor);
77 
78  mem = *object - sizeof(void*);
79  MEM_FREE(mem);
80  *object = NULL;
81  }
82 }
#define MEM_FREE(seg)
Definition: memory.h:28
#define CALL(object, _iface, method,...)
Definition: class/class.h:106

+ Here is the caller graph for this function:

void* classNew ( class_ptr  class,
  ... 
)

Definition at line 58 of file i_class.c.

References classNewParams().

59 {
60  va_list params;
61  void * object;
62 
63  va_start(params, class);
64  object = classNewParams(class, &params);
65  va_end(params);
66 
67  return object;
68 }
void * classNewParams(class_ptr class, va_list *params)
Definition: i_class.c:40

+ Here is the call graph for this function:

void* classNewParams ( class_ptr  ,
va_list *   
)

With this one we can create a new instance via a intermidiary that gets the arguments.

Definition at line 40 of file i_class.c.

References classDelete(), memCalloc(), class_ptr::object_size, and RETCALL.

Referenced by classNew().

41 {
42  void * object = memCalloc(1, class->object_size + sizeof(void*));
43  int ret;
44 
45  * (class_ptr *)object = class;
46  object += sizeof(void*);
47 
48  RETCALL(object, Class, ctor, ret, params);
49 
50  if (-1 == ret) {
51  classDelete(&object);
52  }
53 
54  return object;
55 }
void classDelete(void **object)
Definition: i_class.c:71
#define RETCALL(object, _iface, method, ret,...)
Definition: class/class.h:113
void * memCalloc(size_t, size_t)
Definition: memory.c:818
size_t object_size
Definition: class/class.h:136

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const struct interface i_Class
Initial value:
= {
"class",
3
}

Definition at line 34 of file i_class.c.