1 typedef __SIZE_TYPE__
size_t;
2 typedef const void *t_comptype
;
3 typedef int (*t_compfunc
)(t_comptype
, t_comptype
);
5 extern int *__errno_location(void)
6 __attribute__((__nothrow__
, __leaf__
,__const__
));
7 extern void free(void *__ptr
)
8 __attribute__((__nothrow__
, __leaf__
));
9 extern void *my_malloc1(const char *file
, int line
, size_t size
);
11 int heapsort(void *vbase
, size_t nmemb
, size_t size
, t_compfunc compar
) {
12 char tmp
, *tmp1
, *tmp2
, *abase
, *k
, *p
, *t
;
19 (*__errno_location()) = 22;
23 k
= (char *) my_malloc1(__FILE__
, __LINE__
, size
);
25 abase
= (char *)vbase
- size
;
27 for (l
= nmemb
/ 2 + 1; --l
;) {
28 for (i
= l
; (j
= i
* 2) <= nmemb
; i
= j
) {
30 if (j
< nmemb
&& compar(p
, p
+ size
) < 0) {
35 if (compar(p
, t
) <= 0)
52 tmp2
= abase
+ nmemb
* size
;
59 tmp1
= abase
+ nmemb
* size
;
67 for (i
= 1; (j
= i
* 2) <= nmemb
; i
= j
) {
69 if (j
< nmemb
&& compar(p
, p
+ size
) < 0) {
88 if (j
== 1 || compar(k
, t
) < 0) {