1/* Repeating a memory blob, with alias mapping optimization.
2 Copyright (C) 2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef SUPPORT_BLOB_REPEAT_H
20#define SUPPORT_BLOB_REPEAT_H
21
22#include <stdbool.h>
23#include <stddef.h>
24
25struct support_blob_repeat
26{
27 void *start;
28 size_t size;
29 bool use_malloc;
30};
31
32/* Return an allocation of COUNT elements, each of ELEMENT_SIZE bytes,
33 initialized with the bytes starting at ELEMENT. The memory is
34 writable (and thus counts towards the commit charge). In case of
35 on error, all members of the return struct are zero-initialized,
36 and errno is set accordingly. */
37struct support_blob_repeat support_blob_repeat_allocate (const void *element,
38 size_t element_size,
39 size_t count);
40
41/* Deallocate the blob created by support_blob_repeat_allocate. */
42void support_blob_repeat_free (struct support_blob_repeat *);
43
44#endif /* SUPPORT_BLOB_REPEAT_H */
45