78aa2030 |
/*
|
d54e993e |
* Copyright (C) 2001-2003 FhG Fokus
|
4198a3a2 |
* Copyright (C) 2006-2007 iptelorg GmbH
|
e280d3a5 |
*
|
db26c5ce |
* This file is part of Kamailio, a free SIP server.
|
e280d3a5 |
*
|
db26c5ce |
* Kamailio is free software; you can redistribute it and/or modify
|
e280d3a5 |
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
|
db26c5ce |
* Kamailio is distributed in the hope that it will be useful,
|
e280d3a5 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
|
9e1ff448 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
78aa2030 |
*/
|
a201f9ae |
#include "my_fld.h"
|
6fa0cfe5 |
#include "../../mem/mem.h"
|
4198a3a2 |
#include "../../dprint.h"
|
9bbb835a |
#include "../../lib/srdb2/db_gen.h"
|
a201f9ae |
#include <string.h>
|
c811180f |
|
4198a3a2 |
static void my_fld_free(db_fld_t* fld, struct my_fld* payload)
{
db_drv_free(&payload->gen);
if (payload->buf.s) pkg_free(payload->buf.s);
|
356e43fe |
if (payload->name) pkg_free(payload->name);
|
4198a3a2 |
pkg_free(payload);
}
|
145a90df |
int my_fld(db_fld_t* fld, char* table)
|
c811180f |
{
|
4198a3a2 |
struct my_fld* res;
res = (struct my_fld*)pkg_malloc(sizeof(struct my_fld));
if (res == NULL) {
|
a201f9ae |
ERR("mysql: No memory left\n");
|
452ba322 |
return -1;
|
c4553b38 |
}
|
4198a3a2 |
memset(res, '\0', sizeof(struct my_fld));
if (db_drv_init(&res->gen, my_fld_free) < 0) goto error;
|
95f54932 |
|
4198a3a2 |
DB_SET_PAYLOAD(fld, res);
|
dc117346 |
return 0;
|
4198a3a2 |
error:
if (res) pkg_free(res);
return -1;
|
c811180f |
}
|