forked from github/server
fix symetric db_open and db_close calls.
This commit is contained in:
parent
fee9b6d0a8
commit
9f778c0ae9
|
@ -32,7 +32,7 @@ static void test_command(CuTest * tc) {
|
|||
struct locale * loc;
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
loc = test_create_locale();
|
||||
st = stree_create();
|
||||
CuAssertPtrNotNull(tc, st);
|
||||
|
|
|
@ -14,7 +14,7 @@ static void test_save_load_order(CuTest *tc) {
|
|||
int id;
|
||||
const char * s = "GIB enno 1 Hodor";
|
||||
|
||||
db_open();
|
||||
test_setup();
|
||||
|
||||
odata_create(&od, strlen(s) + 1, s);
|
||||
CuAssertTrue(tc, od->_refcount >= 1);
|
||||
|
@ -28,7 +28,7 @@ static void test_save_load_order(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, s, od->_str);
|
||||
odata_release(od);
|
||||
|
||||
db_close();
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_db_suite(void)
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
|
||||
#include <critbit.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static critbit_tree cb_orders = { 0 };
|
||||
static int auto_id = 0;
|
||||
static int auto_id = -1;
|
||||
|
||||
struct cb_entry {
|
||||
int id;
|
||||
|
@ -50,15 +51,13 @@ static int free_data_cb(const void *match, const void *key, size_t keylen,
|
|||
{
|
||||
struct cb_entry * ent = (struct cb_entry *)match;
|
||||
order_data *od = ent->data;
|
||||
if (od->_refcount > 1) {
|
||||
log_error("refcount=%d for order %d, %s", od->_refcount, ent->id, od->_str);
|
||||
}
|
||||
odata_release(od);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void db_open(void)
|
||||
{
|
||||
assert(auto_id == -1);
|
||||
auto_id = 0;
|
||||
}
|
||||
|
||||
|
@ -66,4 +65,5 @@ void db_close(void)
|
|||
{
|
||||
cb_foreach(&cb_orders, NULL, 0, free_data_cb, NULL);
|
||||
cb_clear(&cb_orders);
|
||||
auto_id = -1;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ static void test_plane(CuTest *tc) {
|
|||
struct region *r;
|
||||
plane *pl;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
CuAssertPtrEquals(tc, 0, findplane(0, 0));
|
||||
CuAssertPtrEquals(tc, 0, getplane(r));
|
||||
|
@ -38,13 +38,14 @@ static void test_plane(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 60, plane_center_y(pl));
|
||||
CuAssertIntEquals(tc, 5, plane_width(pl));
|
||||
CuAssertIntEquals(tc, 41, plane_height(pl));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_origin(CuTest *tc) {
|
||||
struct faction *f;
|
||||
int x, y;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
|
|
@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/log.h>
|
||||
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/db.h>
|
||||
#include <kernel/version.h>
|
||||
#include <kernel/save.h>
|
||||
#include <util/filereader.h>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <platform.h>
|
||||
#include <eressea.h>
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/db.h>
|
||||
#include <CuTest.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
Loading…
Reference in New Issue