1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Move pointer range comparisons into a macro, where they can be dealt with in a more portable way.

FossilOrigin-Name: 05bc4f920ce23da48d1da6cd36a956fd6fd7c862
This commit is contained in:
drh
2015-12-10 17:59:50 +00:00
5 changed files with 28 additions and 18 deletions

View File

@@ -173,6 +173,21 @@
# define SQLITE_PTR_TO_INT(X) ((int)(X))
#endif
/*
** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
** something between S (inclusive) and E (exclusive).
**
** In other words, S is a buffer and E is a pointer to the first byte after
** the end of buffer S. This macro returns true if P points to something
** contained within the buffer S.
*/
#if defined(HAVE_STDINT_H)
# define SQLITE_WITHIN(P,S,E) \
((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E))
#else
# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E))
#endif
/*
** A macro to hint to the compiler that a function should not be
** inlined.