chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/configuration.c, lib/home.c: Introduce environment variables.
[disorder]
/
lib
/
table.h
diff --git
a/lib/table.h
b/lib/table.h
index 12c05c0366fb9915388e81e6c57a0ff7454c79e2..0694fd328b1cc9084d31a911f98e0d2d8e911f21 100644
(file)
--- a/
lib/table.h
+++ b/
lib/table.h
@@
-1,6
+1,6
@@
/*
* This file is part of DisOrder
/*
* This file is part of DisOrder
- * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007, 2008
, 2013
Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-15,15
+15,23
@@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+/** @file lib/table.h
+ * @brief Generic binary search
+ */
#ifndef TABLE_H
#define TABLE_H
#include <stddef.h>
#ifndef TABLE_H
#define TABLE_H
#include <stddef.h>
+#if _WIN32
+#define OFFSETOF_IN_OBJECT(OBJECT,FIELD) ((char *)&(OBJECT).FIELD - (char *)&(OBJECT))
+#else
+#define OFFSETOF_IN_OBJECT(OBJECT,FIELD) offsetof(typeof(OBJECT),FIELD)
+#endif
+
#define TABLE_FIND(TABLE, FIELD, NAME) \
table_find((void *)TABLE, \
#define TABLE_FIND(TABLE, FIELD, NAME) \
table_find((void *)TABLE, \
-
offsetof(typeof((TABLE)[0])
, FIELD), \
+
OFFSETOF_IN_OBJECT(TABLE[0]
, FIELD), \
sizeof ((TABLE)[0]), \
sizeof TABLE / sizeof ((TABLE)[0]), \
NAME)
sizeof ((TABLE)[0]), \
sizeof TABLE / sizeof ((TABLE)[0]), \
NAME)