Browse code

performance and bug fixes

Jiri Kuthan authored on 07/01/2002 04:39:49
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,56 +0,0 @@
1
-/* $Id$
2
- *
3
- * memory related stuff (malloc & friends)
4
- * 
5
- */
6
-
7
-
8
-#ifndef mem_h
9
-#define mem_h
10
-#include "dprint.h"
11
-
12
-#ifdef PKG_MALLOC
13
-#include "q_malloc.h"
14
-
15
-extern struct qm_block* mem_block;
16
-
17
-
18
-#ifdef DBG_QM_MALLOC
19
-
20
-#define pkg_malloc(s) qm_malloc(mem_block, (s),__FILE__, __FUNCTION__, \
21
-								__LINE__);
22
-#define pkg_free(p)   qm_free(mem_block, (p), __FILE__,  __FUNCTION__, \
23
-								__LINE__);
24
-
25
-#else
26
-
27
-#define pkg_malloc(s) qm_malloc(mem_block, (s))
28
-#define pkg_free(p)   qm_free(mem_block, (p))
29
-
30
-#endif
31
-
32
-#define pkg_status()  qm_status(mem_block)
33
-
34
-#elif defined(SHM_MEM) && defined(USE_SHM_MEM)
35
-
36
-#include "shm_mem.h"
37
-
38
-#define pkg_malloc(s) shm_malloc((s))
39
-#define pkg_free(p)   shm_free((p))
40
-#define pkg_status()  shm_status()
41
-
42
-#else
43
-
44
-#include <stdlib.h>
45
-
46
-#define pkg_malloc(s) \
47
-	(  { void *v; v=malloc((s)); \
48
-	   DBG("malloc %x size %d end %x\n", v, s, (unsigned int)v+(s));\
49
-	   v; } )
50
-#define pkg_free(p)  do{ DBG("free %x\n", (p)); free((p)); }while(0);
51
-#define pkg_status()
52
-
53
-#endif
54
-
55
-
56
-#endif
Browse code

- added DBG_QM_MALLOC, when defined qm_malloc & friends (pkg_, shm_) record and display a lot of debuging info (line no, file name, function name); also some extra checks are done (trying to free a pointer twice, trying to free a pointer allocated by other malloc)

Andrei Pelinescu-Onciul authored on 04/12/2001 18:10:50
Showing 1 changed files
... ...
@@ -15,16 +15,28 @@
15 15
 extern struct qm_block* mem_block;
16 16
 
17 17
 
18
-#define pkg_malloc(s) qm_malloc(mem_block, s)
19
-#define pkg_free(p)   qm_free(mem_block, p)
18
+#ifdef DBG_QM_MALLOC
19
+
20
+#define pkg_malloc(s) qm_malloc(mem_block, (s),__FILE__, __FUNCTION__, \
21
+								__LINE__);
22
+#define pkg_free(p)   qm_free(mem_block, (p), __FILE__,  __FUNCTION__, \
23
+								__LINE__);
24
+
25
+#else
26
+
27
+#define pkg_malloc(s) qm_malloc(mem_block, (s))
28
+#define pkg_free(p)   qm_free(mem_block, (p))
29
+
30
+#endif
31
+
20 32
 #define pkg_status()  qm_status(mem_block)
21 33
 
22 34
 #elif defined(SHM_MEM) && defined(USE_SHM_MEM)
23 35
 
24 36
 #include "shm_mem.h"
25 37
 
26
-#define pkg_malloc(s) shm_malloc(s)
27
-#define pkg_free(p)   shm_free(p)
38
+#define pkg_malloc(s) shm_malloc((s))
39
+#define pkg_free(p)   shm_free((p))
28 40
 #define pkg_status()  shm_status()
29 41
 
30 42
 #else
... ...
@@ -32,10 +44,10 @@ extern struct qm_block* mem_block;
32 44
 #include <stdlib.h>
33 45
 
34 46
 #define pkg_malloc(s) \
35
-	(  { void *v; v=malloc(s); \
36
-	   DBG("malloc %x size %d end %x\n", v, s, (unsigned int)v+s);\
47
+	(  { void *v; v=malloc((s)); \
48
+	   DBG("malloc %x size %d end %x\n", v, s, (unsigned int)v+(s));\
37 49
 	   v; } )
38
-#define pkg_free(p)  do{ DBG("free %x\n", p); free(p); }while(0);
50
+#define pkg_free(p)  do{ DBG("free %x\n", (p)); free((p)); }while(0);
39 51
 #define pkg_status()
40 52
 
41 53
 #endif
Browse code

- small but essential fixes

Andrei Pelinescu-Onciul authored on 30/11/2001 01:03:02
Showing 1 changed files
... ...
@@ -23,9 +23,9 @@ extern struct qm_block* mem_block;
23 23
 
24 24
 #include "shm_mem.h"
25 25
 
26
-#define pkg_malloc(s) sh_malloc(s)
27
-#define pkg_free(p)   sh_free(p)
28
-#define pkg_status()  sh_status()
26
+#define pkg_malloc(s) shm_malloc(s)
27
+#define pkg_free(p)   shm_free(p)
28
+#define pkg_status()  shm_status()
29 29
 
30 30
 #else
31 31
 
Browse code

- updated INSTALL - fixed MKDEP in Makefile - added shm_mem.{c,h} = shared memory + shared malloc (sh_malloc)

Andrei Pelinescu-Onciul authored on 26/11/2001 23:31:03
Showing 1 changed files
... ...
@@ -19,7 +19,16 @@ extern struct qm_block* mem_block;
19 19
 #define pkg_free(p)   qm_free(mem_block, p)
20 20
 #define pkg_status()  qm_status(mem_block)
21 21
 
22
+#elif defined(SHM_MEM) && defined(USE_SHM_MEM)
23
+
24
+#include "shm_mem.h"
25
+
26
+#define pkg_malloc(s) sh_malloc(s)
27
+#define pkg_free(p)   sh_free(p)
28
+#define pkg_status()  sh_status()
29
+
22 30
 #else
31
+
23 32
 #include <stdlib.h>
24 33
 
25 34
 #define pkg_malloc(s) \
Browse code

- fixed newly introduce malloc bug

Andrei Pelinescu-Onciul authored on 23/11/2001 10:02:56
Showing 1 changed files
... ...
@@ -7,6 +7,7 @@
7 7
 
8 8
 #ifndef mem_h
9 9
 #define mem_h
10
+#include "dprint.h"
10 11
 
11 12
 #ifdef PKG_MALLOC
12 13
 #include "q_malloc.h"
... ...
@@ -21,8 +22,11 @@ extern struct qm_block* mem_block;
21 22
 #else
22 23
 #include <stdlib.h>
23 24
 
24
-#define pkg_malloc(s) malloc(s)
25
-#define pkg_free(p)  free(p)
25
+#define pkg_malloc(s) \
26
+	(  { void *v; v=malloc(s); \
27
+	   DBG("malloc %x size %d end %x\n", v, s, (unsigned int)v+s);\
28
+	   v; } )
29
+#define pkg_free(p)  do{ DBG("free %x\n", p); free(p); }while(0);
26 30
 #define pkg_status()
27 31
 
28 32
 #endif
Browse code

- malloc replacements

Andrei Pelinescu-Onciul authored on 23/11/2001 09:29:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,31 @@
1
+/* $Id$
2
+ *
3
+ * memory related stuff (malloc & friends)
4
+ * 
5
+ */
6
+
7
+
8
+#ifndef mem_h
9
+#define mem_h
10
+
11
+#ifdef PKG_MALLOC
12
+#include "q_malloc.h"
13
+
14
+extern struct qm_block* mem_block;
15
+
16
+
17
+#define pkg_malloc(s) qm_malloc(mem_block, s)
18
+#define pkg_free(p)   qm_free(mem_block, p)
19
+#define pkg_status()  qm_status(mem_block)
20
+
21
+#else
22
+#include <stdlib.h>
23
+
24
+#define pkg_malloc(s) malloc(s)
25
+#define pkg_free(p)  free(p)
26
+#define pkg_status()
27
+
28
+#endif
29
+
30
+
31
+#endif