Skip to content

Commit

Permalink
Correctly compare queries
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWiederhake committed Feb 27, 2016
1 parent 3396680 commit cf6f5bc
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,24 @@ struct send_file {
int channel;
};

#define memcmp8(a,b) memcmp ((a), (b), 8)
DEFINE_TREE (query, struct query *, memcmp8, 0) ;
static int cmp_ll (long long a, long long b) {
/* Careful: don't convert to int!
* This does NOT always work correctly (although you'll never see the edge cases):
* return a - b; */
if (a > b) {
return 1;
} else if (a < b) {
return -1;
} else {
return 0;
}
}
static int cmp_query (struct query *a, struct query *b) {
int ret = cmp_ll (a->msg_id);
ret = ret ? ret : cmp_ll(a->session_id, b->session_id);
return ret;
}
DEFINE_TREE (query, struct query *, cmp_query, 0) ;

static int mystreq1 (const char *a, const char *b, int l) {
if ((int)strlen (a) != l) { return 1; }
Expand Down

0 comments on commit cf6f5bc

Please sign in to comment.