summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-02-28 06:01:48 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2012-02-28 06:01:48 (GMT)
commit2b061d66d26d1a381aaf2cee0e629bb696e0c9f8 (patch)
tree0a686a39466d121490c278610f5250cd13bbec9e
parent6d349aebe9db752359f485ba07edeec937491c18 (diff)
downloadgrv-2b061d66d26d1a381aaf2cee0e629bb696e0c9f8.zip
grv-2b061d66d26d1a381aaf2cee0e629bb696e0c9f8.tar.gz
grv-2b061d66d26d1a381aaf2cee0e629bb696e0c9f8.tar.bz2
grv-2b061d66d26d1a381aaf2cee0e629bb696e0c9f8.tar.xz
action: Make sure event retiming really *is* a stable sort...
-rw-r--r--action.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/action.c b/action.c
index 602d6c2..1dec134 100644
--- a/action.c
+++ b/action.c
@@ -20,11 +20,13 @@ struct action {
int x, y;
enum actions what;
double when;
+ uint64_t seq;
};
#define MAXACT 80
static struct action actions[MAXACT];
static int action_count;
+static uint64_t next_seq = 0;
void addaction(int x, int y, double when, enum actions what)
{
@@ -41,6 +43,7 @@ void addaction(int x, int y, double when, enum actions what)
actions[i].y = y;
actions[i].when = when;
actions[i].what = what;
+ actions[i].seq = next_seq++;
action_count++;
}
@@ -72,7 +75,7 @@ static int sort_by_time(const void *a, const void *b)
/* This *must* be a stable sort! */
if ( aa->when == bb->when )
- return (aa < bb) ? -1 : 1;
+ return (aa->seq < bb->seq) ? -1 : 1;
else
return (aa->when < bb->when) ? -1 : 1;
}