aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-12-28 09:50:23 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-01-05 11:33:16 -0300
commit448a256359e951fd2e81ccb2926e3f2b1d7a09de (patch)
treea0eb770538013c697f378a35cc035f033381d44f /include
parent47f43160953677faf33853359ee7b973dc487139 (diff)
downloadglibc-448a256359e951fd2e81ccb2926e3f2b1d7a09de.tar
glibc-448a256359e951fd2e81ccb2926e3f2b1d7a09de.tar.gz
glibc-448a256359e951fd2e81ccb2926e3f2b1d7a09de.tar.bz2
glibc-448a256359e951fd2e81ccb2926e3f2b1d7a09de.zip
malloc: Add scratch_buffer_dupfree
It returns a copy of the buffer up to a defined size. It will be used on realpath sync with gnulib.
Diffstat (limited to 'include')
-rw-r--r--include/scratch_buffer.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/scratch_buffer.h b/include/scratch_buffer.h
index f51456444f..36d0bef4bb 100644
--- a/include/scratch_buffer.h
+++ b/include/scratch_buffer.h
@@ -132,4 +132,20 @@ scratch_buffer_set_array_size (struct scratch_buffer *buffer,
(buffer, nelem, size));
}
+/* Return a copy of *BUFFER's first SIZE bytes as a heap-allocated block,
+ deallocating *BUFFER if it was heap-allocated. SIZE must be at
+ most *BUFFER's size. Return NULL (setting errno) on memory
+ exhaustion. */
+void *__libc_scratch_buffer_dupfree (struct scratch_buffer *buffer,
+ size_t size);
+libc_hidden_proto (__libc_scratch_buffer_dupfree)
+
+/* Alias for __libc_scratch_dupfree. */
+static __always_inline void *
+scratch_buffer_dupfree (struct scratch_buffer *buffer, size_t size)
+{
+ void *r = __libc_scratch_buffer_dupfree (buffer, size);
+ return __glibc_likely (r != NULL) ? r : NULL;
+}
+
#endif /* _SCRATCH_BUFFER_H */