add str util
This commit is contained in:
@@ -8,6 +8,7 @@ target_sources(nf7util
|
||||
malloc.h
|
||||
refcnt.h
|
||||
signal.h
|
||||
str.h
|
||||
)
|
||||
target_tests(nf7util
|
||||
array.test.c
|
||||
|
||||
20
util/str.h
Normal file
20
util/str.h
Normal file
@@ -0,0 +1,20 @@
|
||||
// No copyright
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static inline bool nf7util_str_equal_str(
|
||||
const uint8_t* a, uint64_t alen, const uint8_t* b, uint64_t blen) {
|
||||
return
|
||||
alen == blen &&
|
||||
0 == strncmp((const char*) a, (const char*) b, alen);
|
||||
}
|
||||
|
||||
static inline bool nf7util_str_equal_cstr(
|
||||
const uint8_t* a, uint64_t alen, const uint8_t* b) {
|
||||
return
|
||||
alen == strlen((const char*) b) &&
|
||||
0 == strncmp((const char*) a, (const char*) b, alen);
|
||||
}
|
||||
Reference in New Issue
Block a user