Browse code

db_mysql: use generic PKG_MEM_ERROR, SHM_ERROR and SYS_MEM_ERROR helper defines

Henning Westerholt authored on 21/01/2019 22:17:21
Showing 1 changed files
... ...
@@ -43,7 +43,7 @@ int my_fld(db_fld_t* fld, char* table)
43 43
 
44 44
 	res = (struct my_fld*)pkg_malloc(sizeof(struct my_fld));
45 45
 	if (res == NULL) {
46
-		ERR("mysql: No memory left\n");
46
+		PKG_MEM_ERROR;
47 47
 		return -1;
48 48
 	}
49 49
 	memset(res, '\0', sizeof(struct my_fld));
Browse code

db_mysql: coherent indentation and whitespacing

Daniel-Constantin Mierla authored on 09/11/2017 06:03:02
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * Copyright (C) 2001-2003 FhG Fokus
3 3
  * Copyright (C) 2006-2007 iptelorg GmbH
4 4
  *
... ...
@@ -14,8 +14,8 @@
14 14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 15
  * GNU General Public License for more details.
16 16
  *
17
- * You should have received a copy of the GNU General Public License 
18
- * along with this program; if not, write to the Free Software 
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program; if not, write to the Free Software
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20 20
  */
21 21
 
... ...
@@ -52,7 +52,7 @@ int my_fld(db_fld_t* fld, char* table)
52 52
 	DB_SET_PAYLOAD(fld, res);
53 53
 	return 0;
54 54
 
55
- error:
55
+error:
56 56
 	if (res) pkg_free(res);
57 57
 	return -1;
58 58
 }
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
... ...
@@ -21,8 +21,8 @@
21 21
 
22 22
 #include "my_fld.h"
23 23
 
24
-#include "../../mem/mem.h"
25
-#include "../../dprint.h"
24
+#include "../../core/mem/mem.h"
25
+#include "../../core/dprint.h"
26 26
 #include "../../lib/srdb2/db_gen.h"
27 27
 
28 28
 #include <string.h>
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,58 @@
1
+/* 
2
+ * Copyright (C) 2001-2003 FhG Fokus
3
+ * Copyright (C) 2006-2007 iptelorg GmbH
4
+ *
5
+ * This file is part of Kamailio, a free SIP server.
6
+ *
7
+ * Kamailio is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * Kamailio is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License 
18
+ * along with this program; if not, write to the Free Software 
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
+ */
21
+
22
+#include "my_fld.h"
23
+
24
+#include "../../mem/mem.h"
25
+#include "../../dprint.h"
26
+#include "../../lib/srdb2/db_gen.h"
27
+
28
+#include <string.h>
29
+
30
+
31
+static void my_fld_free(db_fld_t* fld, struct my_fld* payload)
32
+{
33
+	db_drv_free(&payload->gen);
34
+	if (payload->buf.s) pkg_free(payload->buf.s);
35
+	if (payload->name) pkg_free(payload->name);
36
+	pkg_free(payload);
37
+}
38
+
39
+
40
+int my_fld(db_fld_t* fld, char* table)
41
+{
42
+	struct my_fld* res;
43
+
44
+	res = (struct my_fld*)pkg_malloc(sizeof(struct my_fld));
45
+	if (res == NULL) {
46
+		ERR("mysql: No memory left\n");
47
+		return -1;
48
+	}
49
+	memset(res, '\0', sizeof(struct my_fld));
50
+	if (db_drv_init(&res->gen, my_fld_free) < 0) goto error;
51
+
52
+	DB_SET_PAYLOAD(fld, res);
53
+	return 0;
54
+
55
+ error:
56
+	if (res) pkg_free(res);
57
+	return -1;
58
+}