Deprecate more mdb_{init|remove}_backends

These functions now use the __attribute__((constructor)) & destructor.
Old names were keep for compatibility

Also put __attribute__((deprecated)) in mdbtools.h for all deprecated
functions.
This commit is contained in:
Nirgal Vourgère
2012-08-09 14:55:17 +02:00
parent 1700860912
commit 5f09513c85
3 changed files with 19 additions and 20 deletions

View File

@@ -237,7 +237,7 @@ quote_with_squotes(const gchar* value)
return quote_generic(value, '\'', '\'');
}
/* deprecated */ char *
char * __attribute__((deprecated))
mdb_get_coltype_string(MdbBackend *backend, int col_type)
{
static int warn_deprecated = 0;
@@ -255,7 +255,7 @@ mdb_get_coltype_string(MdbBackend *backend, int col_type)
return backend->types_table[col_type].name;
}
/* deprecated */ int
int __attribute__((deprecated))
mdb_coltype_takes_length(MdbBackend *backend, int col_type)
{
static int warn_deprecated = 0;
@@ -303,13 +303,17 @@ mdb_colbacktype_takes_length(const MdbColumn *col)
return type->needs_length;
}
void __attribute__((deprecated)) mdb_init_backends() {
fprintf(stderr, "mdb_init_backends() is DEPRECATED and does nothing. Stop calling it.\n");
}
/**
* mdb_init_backends
* _mdb_init_backends
*
* Initializes the mdb_backends hash and loads the builtin backends.
* Use mdb_remove_backends() to destroy this hash when done.
*/
void mdb_init_backends()
void __attribute__ ((constructor)) _mdb_init_backends()
{
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
@@ -382,12 +386,16 @@ void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendTy
g_hash_table_insert(mdb_backends, backend_name, backend);
}
void __attribute__((deprecated)) mdb_remove_backends() {
fprintf(stderr, "mdb_remove_backends() is DEPRECATED and does nothing. Stop calling it.\n");
}
/**
* mdb_remove_backends
*
* Removes all entries from and destroys the mdb_backends hash.
*/
void mdb_remove_backends()
void __attribute__ ((destructor)) _mdb_remove_backends()
{
g_hash_table_foreach_remove(mdb_backends, mdb_drop_backend, NULL);
g_hash_table_destroy(mdb_backends);

View File

@@ -18,15 +18,6 @@
#include "mdbtools.h"
void __attribute__ ((constructor)) _mdb_init()
{
mdb_init_backends();
}
void __attribute__ ((destructor)) _mdb_exit()
{
mdb_remove_backends();
}
void __attribute__((deprecated)) mdb_init()
{
fprintf(stderr, "mdb_init() is DEPRECATED and does nothing. Stop calling it.\n");