diff options
author | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
commit | b34738ed08c2227300d554b139e2495ca5da97d6 (patch) | |
tree | 62f33b52820f2e49f0e53c0f8c636312037c8054 /src/libstrongswan/database/database_factory.c | |
parent | 0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff) | |
download | vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip |
Imported Upstream version 4.6.4
Diffstat (limited to 'src/libstrongswan/database/database_factory.c')
-rw-r--r-- | src/libstrongswan/database/database_factory.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/src/libstrongswan/database/database_factory.c b/src/libstrongswan/database/database_factory.c index 3936565a1..909522d64 100644 --- a/src/libstrongswan/database/database_factory.c +++ b/src/libstrongswan/database/database_factory.c @@ -41,10 +41,8 @@ struct private_database_factory_t { mutex_t *mutex; }; -/** - * Implementation of database_factory_t.create. - */ -static database_t* create(private_database_factory_t *this, char *uri) +METHOD(database_factory_t, create, database_t*, + private_database_factory_t *this, char *uri) { enumerator_t *enumerator; database_t *database = NULL; @@ -65,32 +63,24 @@ static database_t* create(private_database_factory_t *this, char *uri) return database; } -/** - * Implementation of database_factory_t.add_database. - */ -static void add_database(private_database_factory_t *this, - database_constructor_t create) +METHOD(database_factory_t, add_database, void, + private_database_factory_t *this, database_constructor_t create) { this->mutex->lock(this->mutex); this->databases->insert_last(this->databases, create); this->mutex->unlock(this->mutex); } -/** - * Implementation of database_factory_t.remove_database. - */ -static void remove_database(private_database_factory_t *this, - database_constructor_t create) +METHOD(database_factory_t, remove_database, void, + private_database_factory_t *this, database_constructor_t create) { this->mutex->lock(this->mutex); this->databases->remove(this->databases, create, NULL); this->mutex->unlock(this->mutex); } -/** - * Implementation of database_factory_t.destroy - */ -static void destroy(private_database_factory_t *this) +METHOD(database_factory_t, destroy, void, + private_database_factory_t *this) { this->databases->destroy(this->databases); this->mutex->destroy(this->mutex); @@ -102,15 +92,18 @@ static void destroy(private_database_factory_t *this) */ database_factory_t *database_factory_create() { - private_database_factory_t *this = malloc_thing(private_database_factory_t); - - this->public.create = (database_t*(*)(database_factory_t*, char *url))create; - this->public.add_database = (void(*)(database_factory_t*, database_constructor_t))add_database; - this->public.remove_database = (void(*)(database_factory_t*, database_constructor_t))remove_database; - this->public.destroy = (void(*)(database_factory_t*))destroy; - - this->databases = linked_list_create(); - this->mutex = mutex_create(MUTEX_TYPE_DEFAULT); + private_database_factory_t *this; + + INIT(this, + .public = { + .create = _create, + .add_database = _add_database, + .remove_database = _remove_database, + .destroy = _destroy, + }, + .databases = linked_list_create(), + .mutex = mutex_create(MUTEX_TYPE_DEFAULT), + ); return &this->public; } |