From 278b61bc3f2018515e26fd6b45410aded8b6417e Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 16 May 2022 21:07:41 +0100 Subject: Clean up some random bits and bobs --- src/mem.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/mem.h') diff --git a/src/mem.h b/src/mem.h index 3e48a24..077b74d 100644 --- a/src/mem.h +++ b/src/mem.h @@ -68,6 +68,11 @@ static inline void mem_storeptr(void *to, const void *val) { * to any pointer type */ static inline void *mem_offset(void *p, int off) { return (char *)p + off; } +/* returns the offset in bytes from one pointer to another (p - q) */ +static inline ssize mem_diff(const void *p, const void *q) { + return (char *)p - (char *)q; +} + #endif // vi: sw=4 ts=4 noet tw=80 cc=80 -- cgit v1.2.3-54-g00ecf