Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Jeffrey Lee
RISC_OSLib
Commits
70dbde99
Commit
70dbde99
authored
27 years ago
by
Rob Thornburrow
Browse files
Options
Download
Email Patches
Plain Diff
ROM qsort () function is broken so it has been fixed to use the RAM qsort () in both cases.
parent
ef3219a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
c/sort
c/sort
+7
-3
No files found.
c/sort
View file @
70dbde99
...
...
@@ -61,8 +61,10 @@ void *bsearch(const void *key, const void *base,
}
}
#ifndef UROM
/* must not use Shellsort - it is broken (subtracts potentially large
offsets from pointers before comparing with base, can wrap) */
/* #ifndef UROM */
#if 1
/* Qsort is implemented using an explicit stack rather than C recursion */
/* See Sedgewick (Algorithms, Addison Wesley, 1983) for discussion. */
...
...
@@ -263,6 +265,8 @@ void qsort(void *base, size_t nmemb, size_t size,
}
}
#else
/* this is broken - see comments at top of #if */
/* For ROM version we use Shellsort instead of Quicksort for a saving of 880
* bytes. This Shellsort has proven worst case < N^1.5, empirically it is
* much better. Typical average case is either N(LOG(N)^2) or N^1.25.
...
...
@@ -302,7 +306,7 @@ void qsort(void *base, size_t nmemb, size_t size,
pi
+=
4
;
do
{
*
(
int
*
)
p1
=
*
(
int
*
)
p2
;
p1
-=
hsize
;
p1
-=
hsize
;
/* one of the broken bits */
p2
-=
hsize
;
}
while
(
p2
>=
pj
);
*
(
int
*
)
pj
=
t
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment