summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-02-27 09:11:35 +0700
committerhathach <[email protected]>2023-02-27 09:11:35 +0700
commite34aeb5cf69315d2d7711f0a1d040a28492d026d (patch)
tree823a987b9dae178c1261b3ab5050389c0f44a852 /src/common
parent2e47210c1af88b88b6f2d92fe2b6d08117041363 (diff)
minor clean up
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_common.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 78fdcfe36..3e5e1d427 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -84,11 +84,26 @@
#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))
// This is a backport of memset_s from c11
-int32_t tu_memset_s(void *dest, size_t destsz, int ch, size_t count);
+TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count)
+{
+ // TODO may check if desst and src is not NULL
+ if (count > destsz) {
+ return -1;
+ }
+ memset(dest, ch, count);
+ return 0;
+}
// This is a backport of memcpy_s from c11
-int32_t tu_memcpy_s(void *dest, size_t destsz,
- const void * src, size_t count );
+TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count )
+{
+ // TODO may check if desst and src is not NULL
+ if (count > destsz) {
+ return -1;
+ }
+ memcpy(dest, src, count);
+ return 0;
+}
//------------- Bytes -------------//