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,68 +0,0 @@
1
-/* $Id$
2
- *
3
- * simple & fast malloc library
4
- */
5
-
6
-#ifndef q_malloc_h
7
-#define q_malloc_h
8
-
9
-
10
-struct qm_frag{
11
-	unsigned int size;
12
-	union{
13
-		struct qm_frag* nxt_free;
14
-		int is_free;
15
-	}u;
16
-#ifdef DBG_QM_MALLOC
17
-	char* file;
18
-	char* func;
19
-	unsigned int line;
20
-	unsigned int check;
21
-#endif
22
-};
23
-
24
-struct qm_frag_end{
25
-#ifdef DBG_QM_MALLOC
26
-	unsigned int check1;
27
-	unsigned int check2;
28
-#endif
29
-	unsigned int size;
30
-	struct qm_frag* prev_free;
31
-};
32
-
33
-
34
-struct qm_block{
35
-	unsigned int size; /* total size */
36
-	unsigned int used; /* alloc'ed size*/
37
-	unsigned int real_used; /* used+malloc overhead*/
38
-	unsigned int max_real_used;
39
-	
40
-	struct qm_frag* first_frag;
41
-	struct qm_frag_end* last_frag_end;
42
-	
43
-	struct qm_frag free_lst;
44
-	struct qm_frag_end free_lst_end;
45
-};
46
-
47
-
48
-
49
-struct qm_block* qm_malloc_init(char* address, unsigned int size);
50
-
51
-#ifdef DBG_QM_MALLOC
52
-void* qm_malloc(struct qm_block*, unsigned int size, char* file, char* func, 
53
-					unsigned int line);
54
-#else
55
-void* qm_malloc(struct qm_block*, unsigned int size);
56
-#endif
57
-
58
-#ifdef DBG_QM_MALLOC
59
-void  qm_free(struct qm_block*, void* p, char* file, char* func, 
60
-				unsigned int line);
61
-#else
62
-void  qm_free(struct qm_block*, void* p);
63
-#endif
64
-
65
-void  qm_status(struct qm_block*);
66
-
67
-
68
-#endif
Browse code

- fixed free hash table bug - added even more debug support to qm_malloc (-DDBG_QM_MALLOC)

Andrei Pelinescu-Onciul authored on 11/12/2001 07:45:30
Showing 1 changed files
... ...
@@ -17,10 +17,15 @@ struct qm_frag{
17 17
 	char* file;
18 18
 	char* func;
19 19
 	unsigned int line;
20
+	unsigned int check;
20 21
 #endif
21 22
 };
22 23
 
23 24
 struct qm_frag_end{
25
+#ifdef DBG_QM_MALLOC
26
+	unsigned int check1;
27
+	unsigned int check2;
28
+#endif
24 29
 	unsigned int size;
25 30
 	struct qm_frag* prev_free;
26 31
 };
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
... ...
@@ -13,6 +13,11 @@ struct qm_frag{
13 13
 		struct qm_frag* nxt_free;
14 14
 		int is_free;
15 15
 	}u;
16
+#ifdef DBG_QM_MALLOC
17
+	char* file;
18
+	char* func;
19
+	unsigned int line;
20
+#endif
16 21
 };
17 22
 
18 23
 struct qm_frag_end{
... ...
@@ -37,8 +42,21 @@ struct qm_block{
37 42
 
38 43
 
39 44
 struct qm_block* qm_malloc_init(char* address, unsigned int size);
45
+
46
+#ifdef DBG_QM_MALLOC
47
+void* qm_malloc(struct qm_block*, unsigned int size, char* file, char* func, 
48
+					unsigned int line);
49
+#else
40 50
 void* qm_malloc(struct qm_block*, unsigned int size);
51
+#endif
52
+
53
+#ifdef DBG_QM_MALLOC
54
+void  qm_free(struct qm_block*, void* p, char* file, char* func, 
55
+				unsigned int line);
56
+#else
41 57
 void  qm_free(struct qm_block*, void* p);
58
+#endif
59
+
42 60
 void  qm_status(struct qm_block*);
43 61
 
44 62
 
Browse code

- fixed new malloc

Andrei Pelinescu-Onciul authored on 23/11/2001 11:38:33
Showing 1 changed files
... ...
@@ -22,10 +22,10 @@ struct qm_frag_end{
22 22
 
23 23
 
24 24
 struct qm_block{
25
-	unsigned int init_size;
26 25
 	unsigned int size; /* total size */
27 26
 	unsigned int used; /* alloc'ed size*/
28 27
 	unsigned int real_used; /* used+malloc overhead*/
28
+	unsigned int max_real_used;
29 29
 	
30 30
 	struct qm_frag* first_frag;
31 31
 	struct qm_frag_end* last_frag_end;
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,45 @@
1
+/* $Id$
2
+ *
3
+ * simple & fast malloc library
4
+ */
5
+
6
+#ifndef q_malloc_h
7
+#define q_malloc_h
8
+
9
+
10
+struct qm_frag{
11
+	unsigned int size;
12
+	union{
13
+		struct qm_frag* nxt_free;
14
+		int is_free;
15
+	}u;
16
+};
17
+
18
+struct qm_frag_end{
19
+	unsigned int size;
20
+	struct qm_frag* prev_free;
21
+};
22
+
23
+
24
+struct qm_block{
25
+	unsigned int init_size;
26
+	unsigned int size; /* total size */
27
+	unsigned int used; /* alloc'ed size*/
28
+	unsigned int real_used; /* used+malloc overhead*/
29
+	
30
+	struct qm_frag* first_frag;
31
+	struct qm_frag_end* last_frag_end;
32
+	
33
+	struct qm_frag free_lst;
34
+	struct qm_frag_end free_lst_end;
35
+};
36
+
37
+
38
+
39
+struct qm_block* qm_malloc_init(char* address, unsigned int size);
40
+void* qm_malloc(struct qm_block*, unsigned int size);
41
+void  qm_free(struct qm_block*, void* p);
42
+void  qm_status(struct qm_block*);
43
+
44
+
45
+#endif