Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161899506
D58002.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D58002.diff
View Options
diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c
--- a/lib/libc/stdlib/merge.c
+++ b/lib/libc/stdlib/merge.c
@@ -66,25 +66,19 @@
static void setup(u_char *, u_char *, size_t, size_t, cmp_t);
static void insertionsort(u_char *, size_t, size_t, cmp_t);
-#define ISIZE sizeof(int)
#define PSIZE sizeof(u_char *)
-#define ICOPY_LIST(src, dst, last) \
- do \
- *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \
- while(src < last)
-#define ICOPY_ELT(src, dst, i) \
- do \
- *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \
- while (i -= ISIZE)
-
-#define CCOPY_LIST(src, dst, last) \
- do \
- *dst++ = *src++; \
- while (src < last)
-#define CCOPY_ELT(src, dst, i) \
- do \
- *dst++ = *src++; \
- while (i -= 1)
+#define COPY_LIST(src, dst, last) \
+ do { \
+ memcpy(dst, src, last - src); \
+ dst += last - src; \
+ src += last - src; \
+ } while (0)
+#define COPY_ELT(src, dst, i) \
+ do { \
+ memcpy(dst, src, i); \
+ src += i; \
+ dst += i; \
+ } while (0)
/*
* Find the next possible pointer head. (Trickery for forcing an array
@@ -112,7 +106,7 @@
{
size_t i, nbytes, asize;
int sense;
- int big, iflag;
+ int big;
u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
u_char *list2, *list1, *p2, *p, *last, **p1;
@@ -129,10 +123,6 @@
return (-1);
}
- iflag = 0;
- if (__is_aligned(size, ISIZE) && __is_aligned(base, ISIZE))
- iflag = 1;
-
if ((list2 = malloc(asize)) == NULL)
return (-1);
@@ -200,33 +190,17 @@
}
i = size;
if (q == f1) {
- if (iflag) {
- ICOPY_LIST(f2, tp2, b);
- ICOPY_ELT(f1, tp2, i);
- } else {
- CCOPY_LIST(f2, tp2, b);
- CCOPY_ELT(f1, tp2, i);
- }
+ COPY_LIST(f2, tp2, b);
+ COPY_ELT(f1, tp2, i);
} else {
- if (iflag) {
- ICOPY_LIST(f1, tp2, b);
- ICOPY_ELT(f2, tp2, i);
- } else {
- CCOPY_LIST(f1, tp2, b);
- CCOPY_ELT(f2, tp2, i);
- }
+ COPY_LIST(f1, tp2, b);
+ COPY_ELT(f2, tp2, i);
}
}
if (f2 < l2) {
- if (iflag)
- ICOPY_LIST(f2, tp2, l2);
- else
- CCOPY_LIST(f2, tp2, l2);
+ COPY_LIST(f2, tp2, l2);
} else if (f1 < l1) {
- if (iflag)
- ICOPY_LIST(f1, tp2, l1);
- else
- CCOPY_LIST(f1, tp2, l1);
+ COPY_LIST(f1, tp2, l1);
}
*p1 = l2;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 8, 8:31 PM (4 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34604478
Default Alt Text
D58002.diff (2 KB)
Attached To
Mode
D58002: mergesort: use memcpy() for copying
Attached
Detach File
Event Timeline
Log In to Comment