forked from Imagelibrary/littlefs
Compare commits
2 Commits
relaxed-lo
...
easy-util-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a620c730c | ||
|
|
a0c6c54345 |
@@ -11,6 +11,8 @@
|
|||||||
#ifndef LFS_CONFIG
|
#ifndef LFS_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
// If user provides their own CRC impl we don't need this
|
||||||
|
#ifndef LFS_CRC
|
||||||
// Software CRC implementation with small lookup table
|
// Software CRC implementation with small lookup table
|
||||||
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
||||||
static const uint32_t rtable[16] = {
|
static const uint32_t rtable[16] = {
|
||||||
@@ -29,6 +31,7 @@ uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
|||||||
|
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
14
lfs_util.h
14
lfs_util.h
@@ -212,12 +212,20 @@ static inline uint32_t lfs_tobe32(uint32_t a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate CRC-32 with polynomial = 0x04c11db7
|
// Calculate CRC-32 with polynomial = 0x04c11db7
|
||||||
|
#ifdef LFS_CRC
|
||||||
|
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
||||||
|
return LFS_CRC(crc, buffer, size)
|
||||||
|
}
|
||||||
|
#else
|
||||||
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size);
|
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Allocate memory, only used if buffers are not provided to littlefs
|
// Allocate memory, only used if buffers are not provided to littlefs
|
||||||
// Note, memory must be 64-bit aligned
|
// Note, memory must be 64-bit aligned
|
||||||
static inline void *lfs_malloc(size_t size) {
|
static inline void *lfs_malloc(size_t size) {
|
||||||
#ifndef LFS_NO_MALLOC
|
#if defined(LFS_MALLOC)
|
||||||
|
return LFS_MALLOC(size);
|
||||||
|
#elif !defined(LFS_NO_MALLOC)
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
#else
|
#else
|
||||||
(void)size;
|
(void)size;
|
||||||
@@ -227,7 +235,9 @@ static inline void *lfs_malloc(size_t size) {
|
|||||||
|
|
||||||
// Deallocate memory, only used if buffers are not provided to littlefs
|
// Deallocate memory, only used if buffers are not provided to littlefs
|
||||||
static inline void lfs_free(void *p) {
|
static inline void lfs_free(void *p) {
|
||||||
#ifndef LFS_NO_MALLOC
|
#if defined(LFS_FREE)
|
||||||
|
LFS_FREE(p);
|
||||||
|
#elif !defined(LFS_NO_MALLOC)
|
||||||
free(p);
|
free(p);
|
||||||
#else
|
#else
|
||||||
(void)p;
|
(void)p;
|
||||||
|
|||||||
Reference in New Issue
Block a user