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
00024
00035 #include <stdlib.h>
00036 #include <stdio.h>
00037 #include <strings.h>
00038 #include <stdint.h>
00039 #include <string.h>
00040 #include <time.h>
00041
00042 #include "../../lib/srdb2/db_drv.h"
00043 #include "../../mem/mem.h"
00044 #include "../../dprint.h"
00045 #include "../../ut.h"
00046
00047 #include "bdb_fld.h"
00048
00049 static void bdb_fld_free(db_fld_t* fld, bdb_fld_t* payload)
00050 {
00051 db_drv_free(&payload->gen);
00052 if (payload->buf.s) pkg_free(payload->buf.s);
00053 if (payload->name) pkg_free(payload->name);
00054 pkg_free(payload);
00055 }
00056
00057
00058 int bdb_fld(db_fld_t* fld, char* table)
00059 {
00060 bdb_fld_t *res;
00061
00062 res = (bdb_fld_t*)pkg_malloc(sizeof(bdb_fld_t));
00063 if (res == NULL) {
00064 ERR("oracle: No memory left\n");
00065 return -1;
00066 }
00067 memset(res, '\0', sizeof(bdb_fld_t));
00068 res->col_pos = -1;
00069 if (db_drv_init(&res->gen, bdb_fld_free) < 0) goto error;
00070
00071 DB_SET_PAYLOAD(fld, res);
00072 return 0;
00073
00074 error:
00075 if (res) pkg_free(res);
00076 return -1;
00077 }
00078
00079