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.
This commit is contained in:
Enno Rehling 2014-10-18 19:23:36 +02:00
parent 539d2673f7
commit 7e1cec33a2
4 changed files with 14 additions and 38 deletions

View File

@ -35,16 +35,6 @@
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
#include <util/base36.h>
#include <util/event.h>
#include <util/goodies.h>
#include <util/language.h>
#include <util/lists.h>
#include <util/log.h>
#include <util/umlaut.h>
#include <util/parser.h>
#include <util/rng.h>
#include <storage.h> #include <storage.h>
/* libc includes */ /* libc includes */
@ -56,18 +46,11 @@
static int read_permissions(attrib * a, void *owner, struct storage *store) static int read_permissions(attrib * a, void *owner, struct storage *store)
{ {
attrib *attr = NULL; attrib *attr = NULL;
a_read(store, &attr, NULL); a_read(store, &attr, owner);
a_free(attr); a_remove(&attr, a);
return AT_READ_OK; 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) static int read_gmcreate(attrib * a, void *owner, struct storage *store)
{ {
char zText[32]; char zText[32];
@ -75,15 +58,8 @@ static int read_gmcreate(attrib * a, void *owner, struct storage *store)
return AT_READ_OK; 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) void register_gmcmd(void)
{ {
at_register(&at_gmcreate); at_deprecate("GM:create", read_gmcreate);
at_register(&at_permissions); at_deprecate("GM:permissions", read_permissions);
} }

View File

@ -151,14 +151,6 @@ attrib *a_add(attrib ** pa, attrib * a)
return 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) static int a_unlink(attrib ** pa, attrib * a)
{ {
attrib **pnexttype = pa; attrib **pnexttype = pa;
@ -197,6 +189,14 @@ static int a_unlink(attrib ** pa, attrib * a)
return 0; 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 a_remove(attrib ** pa, attrib * a)
{ {
int ok; int ok;

View File

@ -73,7 +73,6 @@ extern "C" {
extern int a_remove(attrib ** pa, attrib * at); extern int a_remove(attrib ** pa, attrib * at);
extern void a_removeall(attrib ** a, const attrib_type * at); extern void a_removeall(attrib ** a, const attrib_type * at);
extern attrib *a_new(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_age(attrib ** attribs);
extern int a_read(struct storage *store, attrib ** attribs, void *owner); extern int a_read(struct storage *store, attrib ** attribs, void *owner);

View File

@ -12,7 +12,8 @@ static void test_attrib_new(CuTest * tc)
CuAssertPtrEquals(tc, 0, a->next); CuAssertPtrEquals(tc, 0, a->next);
CuAssertPtrEquals(tc, 0, a->nexttype); CuAssertPtrEquals(tc, 0, a->nexttype);
CuAssertPtrEquals(tc, (void *)a->type, (void *)&at_test); CuAssertPtrEquals(tc, (void *)a->type, (void *)&at_test);
a_free(a); a_remove(&a, a);
CuAssertPtrEquals(tc, 0, a);
} }