projects
/
platform
/
upstream
/
glib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Simplify code that uses g_queue_insert_before() and insert_after()
[platform/upstream/glib.git]
/
glib
/
gqsort.c
diff --git
a/glib/gqsort.c
b/glib/gqsort.c
index
9463124
..
e63264e
100644
(file)
--- 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
* 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 <http://www.gnu.org/licenses/>.
*/
#include "config.h"
*/
#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 *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;
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);
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:
switch (p->var)
{
case 0:
@@
-178,7
+176,7
@@
msort_with_tmp (const struct msort_param *p, void *b, size_t n)
}
else
{
}
else
{
- mem
p
cpy (tmp, b2, s);
+ memcpy (tmp, b2, s);
tmp += s;
b2 += s;
--n2;
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);
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)
{
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. */
/* 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)
{
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)
{
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);
}
}