X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/5aff007d8fcfb4c6cc3c3627ae15f45562db7a0d..fdbb860d0642a19c29665fadab6b1a1d6229d946:/lib/table.h diff --git a/lib/table.h b/lib/table.h index 11215bb..8cdfcfd 100644 --- a/lib/table.h +++ b/lib/table.h @@ -21,13 +21,13 @@ #ifndef TABLE_H #define TABLE_H -#define TABLE_FIND(TABLE, TYPE, FIELD, NAME) \ - table_find((void *)TABLE, \ - offsetof(TYPE, FIELD), \ - sizeof (TYPE), \ - sizeof TABLE / sizeof (TYPE), \ +#define TABLE_FIND(TABLE, FIELD, NAME) \ + table_find((void *)TABLE, \ + offsetof(typeof((TABLE)[0]), FIELD), \ + sizeof ((TABLE)[0]), \ + sizeof TABLE / sizeof ((TABLE)[0]), \ NAME) -/* Search TYPE TABLE[] for an element where TABLE[N].FIELD matches NAME +/* Search TABLE[] for an element where TABLE[N].FIELD matches NAME * Returns the index N on success or -1 if not found * The table must be lexically sorted on FIELD */