diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2020-10-29 23:54:17 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2020-10-30 14:04:08 -0400 |
commit | 473828ca6aef18c574b8665ae484513e5592af03 (patch) | |
tree | 74d6b8f205ce92282475ad0f6575ea0c5af01fc2 /src/command.c | |
parent | aaf3dc6ac3e3a38b0dd3508d72594214ede27c5c (diff) | |
download | kutter-473828ca6aef18c574b8665ae484513e5592af03.tar.gz kutter-473828ca6aef18c574b8665ae484513e5592af03.tar.xz kutter-473828ca6aef18c574b8665ae484513e5592af03.zip |
command: Add command_decode_ptr() helper
Add a helper function to convert from a string buffer passed in the
args[] parameter to an actual pointer. This avoids all the callers
needing to perfrom pointer manipulation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/command.c b/src/command.c index b0c7f882..e3167baf 100644 --- a/src/command.c +++ b/src/command.c @@ -15,6 +15,18 @@ static uint8_t next_sequence = MESSAGE_DEST; +static uint32_t +command_encode_ptr(void *p) +{ + return (size_t)p; +} + +void * +command_decode_ptr(uint32_t v) +{ + return (void*)(size_t)v; +} + /**************************************************************** * Binary message parsing @@ -78,7 +90,7 @@ command_parsef(uint8_t *p, uint8_t *maxend if (p + len > maxend) goto error; *args++ = len; - *args++ = (size_t)p; + *args++ = command_encode_ptr(p); p += len; break; } |