From 7e1cec33a266ae85f50346ae6900715f918ecd33 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 18 Oct 2014 19:23:36 +0200 Subject: [PATCH] Remove unused gmcmd attributes. use the at_deprecated feature that was built for this purpose. remove final external dependency on a_free in the code. --- src/modules/gmcmd.c | 32 ++++---------------------------- src/util/attrib.c | 16 ++++++++-------- src/util/attrib.h | 1 - src/util/attrib.test.c | 3 ++- 4 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/modules/gmcmd.c b/src/modules/gmcmd.c index 110e418cd..9a5085ecf 100644 --- a/src/modules/gmcmd.c +++ b/src/modules/gmcmd.c @@ -35,16 +35,6 @@ /* util includes */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include /* libc includes */ @@ -56,18 +46,11 @@ static int read_permissions(attrib * a, void *owner, struct storage *store) { attrib *attr = NULL; - a_read(store, &attr, NULL); - a_free(attr); + a_read(store, &attr, owner); + a_remove(&attr, a); return AT_READ_OK; } -struct attrib_type at_permissions = { - "GM:permissions", - NULL, NULL, NULL, - NULL, read_permissions, - ATF_UNIQUE -}; - static int read_gmcreate(attrib * a, void *owner, struct storage *store) { char zText[32]; @@ -75,15 +58,8 @@ static int read_gmcreate(attrib * a, void *owner, struct storage *store) return AT_READ_OK; } -/* at_gmcreate specifies that the owner can create items of a particular type */ -attrib_type at_gmcreate = { - "GM:create", - NULL, NULL, NULL, - NULL, read_gmcreate -}; - void register_gmcmd(void) { - at_register(&at_gmcreate); - at_register(&at_permissions); + at_deprecate("GM:create", read_gmcreate); + at_deprecate("GM:permissions", read_permissions); } diff --git a/src/util/attrib.c b/src/util/attrib.c index 2b83b60ec..7dc067cc4 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -151,14 +151,6 @@ attrib *a_add(attrib ** pa, attrib * a) return a; } -void a_free(attrib * a) -{ - const attrib_type *at = a->type; - if (at->finalize) - at->finalize(a); - free(a); -} - static int a_unlink(attrib ** pa, attrib * a) { attrib **pnexttype = pa; @@ -197,6 +189,14 @@ static int a_unlink(attrib ** pa, attrib * a) return 0; } +static void a_free(attrib * a) +{ + const attrib_type *at = a->type; + if (at->finalize) + at->finalize(a); + free(a); +} + int a_remove(attrib ** pa, attrib * a) { int ok; diff --git a/src/util/attrib.h b/src/util/attrib.h index 2bea8d2b8..7dc3e1a3d 100644 --- a/src/util/attrib.h +++ b/src/util/attrib.h @@ -73,7 +73,6 @@ extern "C" { extern int a_remove(attrib ** pa, attrib * at); extern void a_removeall(attrib ** a, const attrib_type * at); extern attrib *a_new(const attrib_type * at); - extern void a_free(attrib * a); extern int a_age(attrib ** attribs); extern int a_read(struct storage *store, attrib ** attribs, void *owner); diff --git a/src/util/attrib.test.c b/src/util/attrib.test.c index 2790f3edb..2e15c8321 100644 --- a/src/util/attrib.test.c +++ b/src/util/attrib.test.c @@ -12,7 +12,8 @@ static void test_attrib_new(CuTest * tc) CuAssertPtrEquals(tc, 0, a->next); CuAssertPtrEquals(tc, 0, a->nexttype); CuAssertPtrEquals(tc, (void *)a->type, (void *)&at_test); - a_free(a); + a_remove(&a, a); + CuAssertPtrEquals(tc, 0, a); }