diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-04-18 01:01:04 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-24 10:31:31 -0300 |
commit | 1befc494144fbf1d5bff6d7eaeeae4bc20d75f54 (patch) | |
tree | f12641aebdff2700df1262f5bc1c00bea07d88b7 /src/memory.h | |
parent | 471da2de810964052d4d2ab5ba0e23446ea7880d (diff) | |
download | rneovim-1befc494144fbf1d5bff6d7eaeeae4bc20d75f54.tar.gz rneovim-1befc494144fbf1d5bff6d7eaeeae4bc20d75f54.tar.bz2 rneovim-1befc494144fbf1d5bff6d7eaeeae4bc20d75f54.zip |
Use xmalloc() and xmemdupz() in file_pat_to_reg_pat()
Unfortunately there's still a case where NULL can be returned from
file_pat_to_reg_pat().
xmemdupz() and xmallocz() aren't static anymore. There are many use cases for
these function.
Diffstat (limited to 'src/memory.h')
-rw-r--r-- | src/memory.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/memory.h b/src/memory.h index 7a9b9053f3..05ac9359e5 100644 --- a/src/memory.h +++ b/src/memory.h @@ -36,6 +36,23 @@ void *xcalloc(size_t count, size_t size) void *xrealloc(void *ptr, size_t size) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALLOC_SIZE(2) FUNC_ATTR_NONNULL_RET; +/// xmalloc() wrapper that allocates size + 1 bytes and zeroes the last byte +/// +/// @see {xmalloc} +/// @param size +/// @return pointer to allocated space. Never NULL +void *xmallocz(size_t size) FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET; + +/// Allocates (len + 1) bytes of memory, duplicates `len` bytes of +/// `data` to the allocated memory, zero terminates the allocated memory, +/// and returns a pointer to the allocated memory. If the allocation fails, +/// the program dies. +/// +/// @see {xmalloc} +/// @param data Pointer to the data that will be copied +/// @param len number of bytes that will be copied +void *xmemdupz(const void *data, size_t len); + /// strdup() wrapper /// /// @see {xmalloc} |