|
@@ -25,12 +25,54 @@
|
|
|
#include "bitmap/bitmap.h"
|
|
|
#include "dmmlib/dmmlib.h"
|
|
|
|
|
|
-#include <string.h>
|
|
|
-
|
|
|
#ifdef HAVE_LOCKS
|
|
|
#include <pthread.h>
|
|
|
#endif
|
|
|
|
|
|
+
|
|
|
+ * Implementation of memmove()
|
|
|
+ *
|
|
|
+ * Original code at:
|
|
|
+ * http:
|
|
|
+ */
|
|
|
+void * data_move(void *destination, void *source, size_t count);
|
|
|
+
|
|
|
+void * data_move(void *destination, void *source, size_t count) {
|
|
|
+ size_t i = 0;
|
|
|
+
|
|
|
+ char *src = (char *)source;
|
|
|
+ char *dest = (char *)destination;
|
|
|
+ void * ptr = dest;
|
|
|
+
|
|
|
+ char * src_beg = src;
|
|
|
+ char * src_end = src_beg + count;
|
|
|
+
|
|
|
+ char * dest_beg = dest;
|
|
|
+ char * dest_end = dest_beg + count;
|
|
|
+ if(src == dest) {
|
|
|
+ return ptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ if((dest_beg >= src_beg && dest_beg <= src_end) || (dest_end >= src_beg && dest_end <= src_end)) {
|
|
|
+
|
|
|
+
|
|
|
+ for( i = count ; i > 0 ; i--)
|
|
|
+ {
|
|
|
+ *(dest + i) = *(src + i);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ptr;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for( i = 0 ; i < count ; i++)
|
|
|
+ {
|
|
|
+ *(dest + i) = *(src + i);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ptr;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
* Reallocates a memory block from a bitmap-organized raw block
|
|
|
*
|
|
@@ -51,10 +93,10 @@ void * bitmap_realloc(bitmap_rb_t *raw_block, void * ptr,
|
|
|
|
|
|
if(req_size > chunk_header->num_of_cells * raw_block->bytes_per_cell -
|
|
|
CHUNK_HDR_SIZE) {
|
|
|
- ret = memmove(ret, ptr, chunk_header->num_of_cells *
|
|
|
+ ret = data_move(ret, ptr, chunk_header->num_of_cells *
|
|
|
raw_block->bytes_per_cell - CHUNK_HDR_SIZE);
|
|
|
} else {
|
|
|
- ret = memmove(ret, ptr, req_size);
|
|
|
+ ret = data_move(ret, ptr, req_size);
|
|
|
}
|
|
|
|
|
|
#ifdef HAVE_LOCKS
|