Browse code

db_postgres: use generic PKG_MEM_ERROR helper defines, fix missing error log

Henning Westerholt authored on 26/01/2019 17:46:40
Showing 1 changed files
... ...
@@ -53,7 +53,7 @@ int pg_res(db_res_t *res)
53 53
 
54 54
 	pres = (struct pg_res *)pkg_malloc(sizeof(struct pg_res));
55 55
 	if(pres == NULL) {
56
-		ERR("postgres: No memory left\n");
56
+		PKG_MEM_ERROR;
57 57
 		return -1;
58 58
 	}
59 59
 	if(db_drv_init(&pres->gen, pg_res_free) < 0)
Browse code

db_postgres: clang format of the code

Daniel-Constantin Mierla authored on 11/10/2017 16:23:19
Showing 1 changed files
... ...
@@ -38,29 +38,31 @@
38 38
 #include "../../lib/srdb2/db_gen.h"
39 39
 
40 40
 
41
-static void pg_res_free(db_res_t* res, struct pg_res* payload)
41
+static void pg_res_free(db_res_t *res, struct pg_res *payload)
42 42
 {
43 43
 	db_drv_free(&payload->gen);
44
-	if (payload->res) PQclear(payload->res);
44
+	if(payload->res)
45
+		PQclear(payload->res);
45 46
 	pkg_free(payload);
46 47
 }
47 48
 
48 49
 
49
-int pg_res(db_res_t* res)
50
+int pg_res(db_res_t *res)
50 51
 {
51
-	struct pg_res* pres;
52
+	struct pg_res *pres;
52 53
 
53
-	pres = (struct pg_res*)pkg_malloc(sizeof(struct pg_res));
54
-	if (pres == NULL) {
54
+	pres = (struct pg_res *)pkg_malloc(sizeof(struct pg_res));
55
+	if(pres == NULL) {
55 56
 		ERR("postgres: No memory left\n");
56 57
 		return -1;
57 58
 	}
58
-	if (db_drv_init(&pres->gen, pg_res_free) < 0) goto error;
59
+	if(db_drv_init(&pres->gen, pg_res_free) < 0)
60
+		goto error;
59 61
 	DB_SET_PAYLOAD(res, pres);
60 62
 	return 0;
61
-	
62
- error:
63
-	if (pres) {
63
+
64
+error:
65
+	if(pres) {
64 66
 		db_drv_free(&pres->gen);
65 67
 		pkg_free(pres);
66 68
 	}
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -33,8 +33,8 @@
33 33
 #include "pg_res.h"
34 34
 #include "pg_cmd.h"
35 35
 
36
-#include "../../mem/mem.h"
37
-#include "../../dprint.h"
36
+#include "../../core/mem/mem.h"
37
+#include "../../core/dprint.h"
38 38
 #include "../../lib/srdb2/db_gen.h"
39 39
 
40 40
 
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,70 @@
1
+/* 
2
+ * PostgreSQL Database Driver for Kamailio
3
+ *
4
+ * Portions Copyright (C) 2001-2003 FhG FOKUS
5
+ * Copyright (C) 2003 August.Net Services, LLC
6
+ * Portions Copyright (C) 2005-2008 iptelorg GmbH
7
+ *
8
+ * This file is part of Kamailio, a free SIP server.
9
+ *
10
+ * Kamailio is free software; you can redistribute it and/or modify it under the
11
+ * terms of the GNU General Public License as published by the Free Software
12
+ * Foundation; either version 2 of the License, or (at your option) any later
13
+ * version
14
+ *
15
+ * Kamailio is distributed in the hope that it will be useful, but WITHOUT ANY
16
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18
+ * details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License along
21
+ * with this program; if not, write to the Free Software Foundation, Inc., 59
22
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
+ */
24
+
25
+/** \addtogroup postgres
26
+ * @{ 
27
+ */
28
+
29
+/** \file
30
+ * Functions working with result structures received from PostgreSQL servers.
31
+ */
32
+
33
+#include "pg_res.h"
34
+#include "pg_cmd.h"
35
+
36
+#include "../../mem/mem.h"
37
+#include "../../dprint.h"
38
+#include "../../lib/srdb2/db_gen.h"
39
+
40
+
41
+static void pg_res_free(db_res_t* res, struct pg_res* payload)
42
+{
43
+	db_drv_free(&payload->gen);
44
+	if (payload->res) PQclear(payload->res);
45
+	pkg_free(payload);
46
+}
47
+
48
+
49
+int pg_res(db_res_t* res)
50
+{
51
+	struct pg_res* pres;
52
+
53
+	pres = (struct pg_res*)pkg_malloc(sizeof(struct pg_res));
54
+	if (pres == NULL) {
55
+		ERR("postgres: No memory left\n");
56
+		return -1;
57
+	}
58
+	if (db_drv_init(&pres->gen, pg_res_free) < 0) goto error;
59
+	DB_SET_PAYLOAD(res, pres);
60
+	return 0;
61
+	
62
+ error:
63
+	if (pres) {
64
+		db_drv_free(&pres->gen);
65
+		pkg_free(pres);
66
+	}
67
+	return -1;
68
+}
69
+
70
+/** @} */