diff options
author | Karl Williamson <khw@cpan.org> | 2017-10-31 12:11:12 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-11-06 12:50:05 -0700 |
commit | bdb7e3f0f6e41516d2c50d43e5f3f1373db014b0 (patch) | |
tree | e4df1a5eaccf25e2de3d8efc81351ab65659f79a /handy.h | |
parent | f55ac4a45513e50ae06769ee748ea079c9577a7f (diff) | |
download | perl-bdb7e3f0f6e41516d2c50d43e5f3f1373db014b0.tar.gz |
Add memBEGINs(), memENDs() and use them in APItest
memBEGINs() is like strBEGINs(), but can be used for buffers without
trailing NULs. It can also be used when there is a trailing NUL, and
the length is known, as it should be somewhat faster, only having to
check for one ending condition.
Same for memENDs vs strENDs
Diffstat (limited to 'handy.h')
-rw-r--r-- | handy.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -492,6 +492,13 @@ Returns zero if non-equal, or non-zero if equal. (memEQ((s1), ("" s2 ""), (sizeof(s2)-1))) #define _memNEs(s1, s2) (memNE((s1),("" s2 ""),(sizeof(s2)-1))) +#define memBEGINs(s1, l, s2) \ + ( (l) >= sizeof(s2) - 1 \ + && memEQ(s1, "" s2 "", sizeof(s2)-1)) +#define memENDs(s1, l, s2) \ + ( (l) >= sizeof(s2) - 1 \ + && memEQ(s1 + (l) - (sizeof(s2) - 1), "" s2 "", sizeof(s2)-1)) + #define memLT(s1,s2,l) (memcmp(s1,s2,l) < 0) #define memLE(s1,s2,l) (memcmp(s1,s2,l) <= 0) #define memGT(s1,s2,l) (memcmp(s1,s2,l) > 0) |