Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=28c9bf1628164d5e4972757ff20c9fe26f880f22
commit 28c9bf1628164d5e4972757ff20c9fe26f880f22 Author: Michel Hermier <[email protected]> Date: Mon Apr 28 19:00:48 2014 +0200 libpacman: Remove C object implementation. diff --git a/lib/libpacman/object.cpp b/lib/libpacman/object.cpp index ab51a8f..ad9b300 100644 --- a/lib/libpacman/object.cpp +++ b/lib/libpacman/object.cpp @@ -53,86 +53,4 @@ int Object::set(unsigned val, unsigned long data) return -1; } -struct __pmobject_t *_pacman_object_alloc(size_t size, const struct __pmobject_operations_t *object_operations, struct __pmobject_private_t *object_private) -{ - struct __pmobject_t *ret; - - ASSERT(size >= sizeof(*ret), RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - - if((ret = _pacman_objectmemory_alloc(size, object_operations)) != NULL) { - ret->object_private = object_private; - } - return ret; -} - -int _pacman_object_delete(struct __pmobject_t *self) -{ - ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - ASSERT(self->operations == NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - - if(self->operations->fini != NULL) { - self->operations->fini(self); - } - f_free(self); - return 0; -} - -int _pacman_object_init(struct __pmobject_t *self, struct __pmobject_private_t *object_private) -{ - ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - - self->object_private = object_private; - return 0; -} - -int _pacman_object_fini(struct __pmobject_t *self) -{ - ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - ASSERT(self->operations != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - - self->operations = NULL; - return 0; -} - -const struct __pmobject_operations_t *_pacman_object_operations(struct __pmobject_t *self) -{ - ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - ASSERT(self->operations != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - - return self->operations; -} - -int _pacman_object_get(struct __pmobject_t *self, unsigned val, unsigned long *data) -{ - const struct __pmobject_operations_t *object_operations; - - ASSERT((object_operations = _pacman_object_operations(self)) != NULL, return -1); - ASSERT(object_operations->get != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - - return object_operations->get(self, val, data); -} - -int _pacman_object_set(struct __pmobject_t *self, unsigned val, unsigned long data) -{ - const struct __pmobject_operations_t *object_operations; - - ASSERT((object_operations = _pacman_object_operations(self)) != NULL, return -1); - ASSERT(object_operations->set != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - - return object_operations->set(self, val, data); -} - -struct __pmobject_t *_pacman_objectmemory_alloc(size_t size, const struct __pmobject_operations_t *object_operations) -{ - struct __pmobject_t *ret; - - ASSERT(size >= sizeof(*ret), RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - ASSERT(object_operations != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - - if((ret = f_zalloc(size)) != NULL) { - ret->operations = object_operations; - } - return ret; -} - /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/object.h b/lib/libpacman/object.h index 63a2034..e6b3f12 100644 --- a/lib/libpacman/object.h +++ b/lib/libpacman/object.h @@ -40,38 +40,6 @@ public: } -struct __pmobject_t; -struct __pmobject_private_t; - -struct __pmobject_operations_t -{ - int (*fini)(struct __pmobject_t *object); - - int (*get)(struct __pmobject_t *object, unsigned val, unsigned long *data); - int (*set)(struct __pmobject_t *object, unsigned val, unsigned long data); -}; - -struct __pmobject_t -{ - const struct __pmobject_operations_t *operations; - - struct __pmobject_private_t *object_private; -}; - -struct __pmobject_t *_pacman_object_alloc(size_t size, const struct __pmobject_operations_t *object_operations, struct __pmobject_private_t *object_private); - -int _pacman_object_delete(struct __pmobject_t *self); - -int _pacman_object_init(struct __pmobject_t *self, struct __pmobject_private_t *object_private); -int _pacman_object_fini(struct __pmobject_t *self); - -const struct __pmobject_operations_t *_pacman_object_operations(struct __pmobject_t *self); - -int _pacman_object_get(struct __pmobject_t *self, unsigned val, unsigned long *data); -int _pacman_object_set(struct __pmobject_t *self, unsigned val, unsigned long data); - -struct __pmobject_t *_pacman_objectmemory_alloc(size_t size, const struct __pmobject_operations_t *object_operations); - #endif /* _PACMAN__OBJECT_H */ /* vim: set ts=2 sw=2 noet: */ _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
