Browse code

core: mem - use size_t for fm memory management functions

Daniel-Constantin Mierla authored on 08/06/2016 08:03:18
Showing 2 changed files
... ...
@@ -262,19 +262,19 @@ static inline void fm_insert_free(struct fm_block* qm, struct fm_frag* frag)
262 262
  * \param size fragement size
263 263
  */
264 264
 static inline
265
-#ifdef DBG_F_MALLOC 
265
+#ifdef DBG_F_MALLOC
266 266
 void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
267
-					unsigned long size,
267
+					size_t size,
268 268
 					const char* file, const char* func, unsigned int line,
269 269
 					const char* mname)
270 270
 #else
271 271
 void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
272
-					unsigned long size)
272
+					size_t size)
273 273
 #endif
274 274
 {
275
-	unsigned long rest;
275
+	size_t rest;
276 276
 	struct fm_frag* n;
277
-	
277
+
278 278
 	rest=frag->size-size;
279 279
 #ifdef MEM_FRAG_AVOIDANCE
280 280
 	if ((rest> (FRAG_OVERHEAD+F_MALLOC_OPTIMIZE))||
... ...
@@ -316,7 +316,7 @@ struct fm_block* fm_malloc_init(char* address, unsigned long size, int type)
316 316
 	char* end;
317 317
 	struct fm_block* qm;
318 318
 	unsigned long init_overhead;
319
-	
319
+
320 320
 	/* make address and size multiple of 8*/
321 321
 	start=(char*)ROUNDUP((unsigned long) address);
322 322
 	DBG("fm_malloc_init: F_OPTIMIZE=%lu, /ROUNDTO=%lu\n",
... ...
@@ -331,8 +331,7 @@ struct fm_block* fm_malloc_init(char* address, unsigned long size, int type)
331 331
 	size=ROUNDDOWN(size);
332 332
 
333 333
 	init_overhead=INIT_OVERHEAD;
334
-	
335
-	
334
+
336 335
 	if (size < init_overhead)
337 336
 	{
338 337
 		/* not enough mem to create our control structures !!!*/
... ...
@@ -378,7 +377,7 @@ struct fm_block* fm_malloc_init(char* address, unsigned long size, int type)
378 377
  * \param size memory allocation size
379 378
  * \return address of allocated memory
380 379
  */
381
-struct fm_frag* fm_search_defrag(struct fm_block* qm, unsigned long size)
380
+struct fm_frag* fm_search_defrag(struct fm_block* qm, size_t size)
382 381
 {
383 382
 	struct fm_frag* frag;
384 383
 	struct fm_frag* nxt;
... ...
@@ -424,10 +423,10 @@ struct fm_frag* fm_search_defrag(struct fm_block* qm, unsigned long size)
424 423
  * \return address of allocated memory
425 424
  */
426 425
 #ifdef DBG_F_MALLOC
427
-void* fm_malloc(void* qmp, unsigned long size, const char* file,
426
+void* fm_malloc(void* qmp, size_t size, const char* file,
428 427
                     const char* func, unsigned int line, const char* mname)
429 428
 #else
430
-void* fm_malloc(void* qmp, unsigned long size)
429
+void* fm_malloc(void* qmp, size_t size)
431 430
 #endif
432 431
 {
433 432
 	struct fm_block* qm;
... ...
@@ -634,17 +633,17 @@ void fm_free(void* qmp, void* p)
634 633
  * \return reallocated memory block
635 634
  */
636 635
 #ifdef DBG_F_MALLOC
637
-void* fm_realloc(void* qmp, void* p, unsigned long size,
636
+void* fm_realloc(void* qmp, void* p, size_t size,
638 637
 					const char* file, const char* func, unsigned int line,
639 638
 					const char *mname)
640 639
 #else
641
-void* fm_realloc(void* qmp, void* p, unsigned long size)
640
+void* fm_realloc(void* qmp, void* p, size_t size)
642 641
 #endif
643 642
 {
644 643
 	struct fm_block* qm;
645 644
 	struct fm_frag *f;
646
-	unsigned long diff;
647
-	unsigned long orig_size;
645
+	size_t diff;
646
+	size_t orig_size;
648 647
 	struct fm_frag *n;
649 648
 	void *ptr;
650 649
 
... ...
@@ -1095,7 +1094,7 @@ static struct fm_block *_fm_shm_block = 0;
1095 1094
 
1096 1095
 /*SHM wrappers to sync the access to memory block*/
1097 1096
 #ifdef DBG_F_MALLOC
1098
-void* fm_shm_malloc(void* qmp, unsigned long size,
1097
+void* fm_shm_malloc(void* qmp, size_t size,
1099 1098
 					const char* file, const char* func, unsigned int line, const char* mname)
1100 1099
 {
1101 1100
 	void *r;
... ...
@@ -1104,7 +1103,7 @@ void* fm_shm_malloc(void* qmp, unsigned long size,
1104 1103
 	shm_unlock();
1105 1104
 	return r;
1106 1105
 }
1107
-void* fm_shm_realloc(void* qmp, void* p, unsigned long size,
1106
+void* fm_shm_realloc(void* qmp, void* p, size_t size,
1108 1107
 					const char* file, const char* func, unsigned int line, const char* mname)
1109 1108
 {
1110 1109
 	void *r;
... ...
@@ -1113,7 +1112,7 @@ void* fm_shm_realloc(void* qmp, void* p, unsigned long size,
1113 1112
 	shm_unlock();
1114 1113
 	return r;
1115 1114
 }
1116
-void* fm_shm_resize(void* qmp, void* p, unsigned long size,
1115
+void* fm_shm_resize(void* qmp, void* p, size_t size,
1117 1116
 					const char* file, const char* func, unsigned int line, const char* mname)
1118 1117
 {
1119 1118
 	void *r;
... ...
@@ -1131,7 +1130,7 @@ void fm_shm_free(void* qmp, void* p, const char* file, const char* func,
1131 1130
 	shm_unlock();
1132 1131
 }
1133 1132
 #else
1134
-void* fm_shm_malloc(void* qmp, unsigned long size)
1133
+void* fm_shm_malloc(void* qmp, size_t size)
1135 1134
 {
1136 1135
 	void *r;
1137 1136
 	shm_lock();
... ...
@@ -1139,7 +1138,7 @@ void* fm_shm_malloc(void* qmp, unsigned long size)
1139 1138
 	shm_unlock();
1140 1139
 	return r;
1141 1140
 }
1142
-void* fm_shm_realloc(void* qmp, void* p, unsigned long size)
1141
+void* fm_shm_realloc(void* qmp, void* p, size_t size)
1143 1142
 {
1144 1143
 	void *r;
1145 1144
 	shm_lock();
... ...
@@ -1147,7 +1146,7 @@ void* fm_shm_realloc(void* qmp, void* p, unsigned long size)
1147 1146
 	shm_unlock();
1148 1147
 	return r;
1149 1148
 }
1150
-void* fm_shm_resize(void* qmp, void* p, unsigned long size)
1149
+void* fm_shm_resize(void* qmp, void* p, size_t size)
1151 1150
 {
1152 1151
 	void *r;
1153 1152
 	shm_lock();
... ...
@@ -134,11 +134,11 @@ struct fm_block* fm_malloc_init(char* address, unsigned long size, int type);
134 134
  * \return address of allocated memory
135 135
  */
136 136
 #ifdef DBG_F_MALLOC
137
-void* fm_malloc(void* qmp, unsigned long size,
137
+void* fm_malloc(void* qmp, size_t size,
138 138
 					const char* file, const char* func, unsigned int line,
139 139
 					const char* mname);
140 140
 #else
141
-void* fm_malloc(void* qmp, unsigned long size);
141
+void* fm_malloc(void* qmp, size_t size);
142 142
 #endif
143 143
 
144 144
 
... ...
@@ -167,10 +167,10 @@ void  fm_free(void* qmp, void* p);
167 167
  * \return reallocated memory block
168 168
  */
169 169
 #ifdef DBG_F_MALLOC
170
-void* fm_realloc(void* qmp, void* p, unsigned long size,
170
+void* fm_realloc(void* qmp, void* p, size_t size,
171 171
 					const char* file, const char* func, unsigned int line, const char *mname);
172 172
 #else
173
-void*  fm_realloc(void* qmp, void* p, unsigned long size);
173
+void*  fm_realloc(void* qmp, void* p, size_t size);
174 174
 #endif
175 175
 
176 176