diff options
Diffstat (limited to 'src/nvim/memory.c')
-rw-r--r-- | src/nvim/memory.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 8db47b79c1..3e041be4d3 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -440,6 +440,16 @@ void do_outofmem_msg(size_t size) } } +/// Writes time_t to "buf[8]". +void time_to_bytes(time_t time_, uint8_t buf[8]) +{ + // time_t can be up to 8 bytes in size, more than uintmax_t in 32 bits + // systems, thus we can't use put_bytes() here. + for (size_t i = 7, bufi = 0; bufi < 8; i--, bufi++) { + buf[bufi] = (uint8_t)((uint64_t)time_ >> (i * 8)); + } +} + #if defined(EXITFREE) #include "nvim/file_search.h" |