From 83fe139b2b9c37db50c14833cb38877b999db6de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Jul 2016 15:42:50 +1000 Subject: Undo: use system memcmp `my_memcmp` didn't work properly comparing memory sizes not aligned to 4 bytes, this worked while we used guarded-alloc (which always wrote a guard at the end of each allocation). Since moving to lockfree allocator it could read uninitialized memory. It also consistently performed ~10-30% worse then glibc's. This is typically well optimized, no need to do ourselves. --- source/blender/blenloader/intern/undofile.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index d0dc9a88cc0..c191e48a143 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -80,20 +80,6 @@ void BLO_memfile_merge(MemFile *first, MemFile *second) BLO_memfile_free(first); } -static int my_memcmp(const int *mem1, const int *mem2, const int len) -{ - register int a = len; - register const int *mema = mem1; - register const int *memb = mem2; - - while (a--) { - if (*mema != *memb) return 1; - mema++; - memb++; - } - return 0; -} - void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsigned int size) { static MemFileChunk *compchunk = NULL; @@ -118,7 +104,7 @@ void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsi /* we compare compchunk with buf */ if (compchunk) { if (compchunk->size == curchunk->size) { - if (my_memcmp((int *)compchunk->buf, (const int *)buf, size / 4) == 0) { + if (memcmp(compchunk->buf, buf, size) == 0) { curchunk->buf = compchunk->buf; curchunk->ident = 1; } -- cgit v1.2.3