Skip to content

Commit 8512ab0

Browse files
committed
Add align_size() to utils_common.h
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent e929d58 commit 8512ab0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/utils/utils_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ extern "C" {
2020
#define __TLS __thread
2121
#endif
2222

23+
static inline size_t align_size(size_t size, size_t alignment) {
24+
// align size to 'alignment' bytes
25+
size_t rest = size & (alignment - 1);
26+
if (rest) {
27+
return (size - rest + alignment);
28+
} else {
29+
return size;
30+
}
31+
}
32+
2333
#ifdef __cplusplus
2434
}
2535
#endif

0 commit comments

Comments
 (0)