1717#include " src/string/memory_utils/inline_memmove.h"
1818#include " src/string/memory_utils/inline_memset.h"
1919
20- using namespace LIBC_NAMESPACE ;
20+ using LIBC_NAMESPACE::FreeListHeap;
21+ using LIBC_NAMESPACE::cpp::nullopt ;
22+ using LIBC_NAMESPACE::cpp::optional;
23+ using LIBC_NAMESPACE::inline_memset;
2124
2225// Record of an outstanding allocation.
2326struct Alloc {
@@ -55,8 +58,8 @@ class AllocVec {
5558 Alloc &operator [](size_t idx) { return allocs[idx]; }
5659
5760 void erase_idx (size_t idx) {
58- inline_memmove (&allocs[idx], &allocs[idx + 1 ],
59- sizeof (Alloc) * (size_ - idx - 1 ));
61+ LIBC_NAMESPACE:: inline_memmove (&allocs[idx], &allocs[idx + 1 ],
62+ sizeof (Alloc) * (size_ - idx - 1 ));
6063 --size_;
6164 }
6265
@@ -69,11 +72,11 @@ class AllocVec {
6972
7073// Choose a T value by casting libfuzzer data or exit.
7174template <typename T>
72- cpp:: optional<T> choose (const uint8_t *&data, size_t &remainder) {
75+ optional<T> choose (const uint8_t *&data, size_t &remainder) {
7376 if (sizeof (T) > remainder)
74- return cpp:: nullopt ;
77+ return nullopt ;
7578 T out;
76- inline_memcpy (&out, data, sizeof (T));
79+ LIBC_NAMESPACE:: inline_memcpy (&out, data, sizeof (T));
7780 data += sizeof (T);
7881 remainder -= sizeof (T);
7982 return out;
@@ -89,32 +92,30 @@ enum class AllocType : uint8_t {
8992};
9093
9194template <>
92- cpp::optional<AllocType> choose<AllocType>(const uint8_t *&data,
93- size_t &remainder) {
95+ optional<AllocType> choose<AllocType>(const uint8_t *&data, size_t &remainder) {
9496 auto raw = choose<uint8_t >(data, remainder);
9597 if (!raw)
96- return cpp:: nullopt ;
98+ return nullopt ;
9799 return static_cast <AllocType>(
98100 *raw % static_cast <uint8_t >(AllocType::NUM_ALLOC_TYPES));
99101}
100102
101103constexpr size_t heap_size = 64 * 1024 ;
102104
103- cpp:: optional<size_t > choose_size (const uint8_t *&data, size_t &remainder) {
105+ optional<size_t > choose_size (const uint8_t *&data, size_t &remainder) {
104106 auto raw = choose<size_t >(data, remainder);
105107 if (!raw)
106- return cpp:: nullopt ;
108+ return nullopt ;
107109 return *raw % heap_size;
108110}
109111
110- cpp::optional<size_t > choose_alloc_idx (const AllocVec &allocs,
111- const uint8_t *&data,
112- size_t &remainder) {
112+ optional<size_t > choose_alloc_idx (const AllocVec &allocs, const uint8_t *&data,
113+ size_t &remainder) {
113114 if (allocs.empty ())
114- return cpp:: nullopt ;
115+ return nullopt ;
115116 auto raw = choose<size_t >(data, remainder);
116117 if (!raw)
117- return cpp:: nullopt ;
118+ return nullopt ;
118119 return *raw % allocs.size ();
119120}
120121
@@ -125,7 +126,7 @@ cpp::optional<size_t> choose_alloc_idx(const AllocVec &allocs,
125126 TYPE NAME = *maybe_##NAME
126127
127128extern " C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t remainder) {
128- FreeListHeapBuffer<heap_size> heap;
129+ LIBC_NAMESPACE:: FreeListHeapBuffer<heap_size> heap;
129130 AllocVec allocs (heap);
130131
131132 uint8_t canary = 0 ;
@@ -144,7 +145,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t remainder) {
144145 break ;
145146 case AllocType::ALIGNED_ALLOC: {
146147 ASSIGN_OR_RETURN (size_t , alignment, choose_size (data, remainder));
147- alignment = cpp::bit_ceil (alignment);
148+ alignment = LIBC_NAMESPACE:: cpp::bit_ceil (alignment);
148149 ptr = heap.aligned_allocate (alignment, alloc_size);
149150 break ;
150151 }
0 commit comments