X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=glib%2Fgqsort.c;h=e63264ea4f5491fc66d3d667cbd2bbbc70486aa1;hb=20f6cc2a10ba26860e7a6d27c100deadb5497772;hp=9463124a7a312648a9f70db4a32fed8f8746d9b2;hpb=839957f275875b6f8fd033d67379bce0fde1c58f;p=platform%2Fupstream%2Fglib.git diff --git a/glib/gqsort.c b/glib/gqsort.c index 9463124..e63264e 100644 --- a/glib/gqsort.c +++ b/glib/gqsort.c @@ -14,9 +14,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library; if not, see . */ #include "config.h" @@ -71,6 +69,10 @@ msort_with_tmp (const struct msort_param *p, void *b, size_t n) { char *b1, *b2; size_t n1, n2; + char *tmp = p->t; + const size_t s = p->s; + GCompareDataFunc cmp = p->cmp; + void *arg = p->arg; if (n <= 1) return; @@ -83,10 +85,6 @@ msort_with_tmp (const struct msort_param *p, void *b, size_t n) msort_with_tmp (p, b1, n1); msort_with_tmp (p, b2, n2); - char *tmp = p->t; - const size_t s = p->s; - GCompareDataFunc cmp = p->cmp; - void *arg = p->arg; switch (p->var) { case 0: @@ -178,7 +176,7 @@ msort_with_tmp (const struct msort_param *p, void *b, size_t n) } else { - mempcpy (tmp, b2, s); + memcpy (tmp, b2, s); tmp += s; b2 += s; --n2; @@ -226,6 +224,8 @@ msort_r (void *b, size_t n, size_t s, GCompareDataFunc cmp, void *arg) void **tp = (void **) (p.t + n * sizeof (void *)); void **t = tp; void *tmp_storage = (void *) (tp + n); + char *kp; + size_t i; while ((void *) t < tmp_storage) { @@ -238,8 +238,6 @@ msort_r (void *b, size_t n, size_t s, GCompareDataFunc cmp, void *arg) /* tp[0] .. tp[n - 1] is now sorted, copy around entries of the original array. Knuth vol. 3 (2nd ed.) exercise 5.2-10. */ - char *kp; - size_t i; for (i = 0, ip = (char *) b; i < n; i++, ip += s) if ((kp = tp[i]) != ip) { @@ -302,5 +300,5 @@ g_qsort_with_data (gconstpointer pbase, GCompareDataFunc compare_func, gpointer user_data) { - return msort_r (pbase, total_elems, size, compare_func, user_data); + msort_r ((gpointer)pbase, total_elems, size, compare_func, user_data); }