1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws_ptr_diff_size_t

lws_ptr_diff() is a very handy helper reducing the pointer delta to an int
count of bytes... however many times we actually want a size_t count of bytes
since that's the type of the argument we're trying to feed.

Let's establish a variant that naturally issues size_t.
This commit is contained in:
Andy Green 2020-12-24 16:10:32 +00:00
parent 9b42fc6aae
commit 454adf55ef

View file

@ -186,6 +186,9 @@ lws_buflist_describe(struct lws_buflist **head, void *id, const char *reason);
#define lws_ptr_diff(head, tail) \
((int)((char *)(head) - (char *)(tail)))
#define lws_ptr_diff_size_t(head, tail) \
((size_t)(ssize_t)((char *)(head) - (char *)(tail)))
/**
* lws_snprintf(): snprintf that truncates the returned length too
*