Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031 #include <db.h>
00032
00033 #include "bdb_res.h"
00034 #include "bdb_cmd.h"
00035 #include "bdb_crs_compat.h"
00036
00037 #include "../../mem/mem.h"
00038 #include "../../dprint.h"
00039 #include "../../lib/srdb2/db_gen.h"
00040
00041
00042 void bdb_res_free(db_res_t* res, bdb_res_t *payload)
00043 {
00044 bdb_cmd_t *bcmd;
00045
00046 bcmd = DB_GET_PAYLOAD(res->cmd);
00047
00048
00049
00050 if(bcmd->dbcp!=NULL)
00051 {
00052 bcmd->dbcp->CLOSE_CURSOR(bcmd->dbcp);
00053 bcmd->dbcp = NULL;
00054 }
00055 db_drv_free(&payload->gen);
00056 pkg_free(payload);
00057 }
00058
00059
00060
00061
00062
00063
00064
00065 int bdb_res(db_res_t* res)
00066 {
00067 bdb_res_t *br;
00068
00069 br = (bdb_res_t*)pkg_malloc(sizeof(bdb_res_t));
00070 if (br == NULL) {
00071 ERR("bdb: No memory left\n");
00072 return -1;
00073 }
00074 if (db_drv_init(&br->gen, bdb_res_free) < 0) goto error;
00075 DB_SET_PAYLOAD(res, br);
00076 return 0;
00077
00078 error:
00079 if (br) {
00080 db_drv_free(&br->gen);
00081 pkg_free(br);
00082 }
00083 return -1;
00084 }