31#ifndef CPL_MASK_H_INCLUDED
32#define CPL_MASK_H_INCLUDED
47inline GUInt32 *CPLMaskCreate(std::size_t size,
bool default_value)
49 std::size_t nBytes = (size + 31) / 8;
55 std::memset(buf, default_value ? 0xff : 0, nBytes);
56 return static_cast<GUInt32 *
>(buf);
66inline bool CPLMaskGet(
GUInt32 *mask, std::size_t i)
68 return mask[i >> 5] & (0x01 << (i & 0x1f));
77inline void CPLMaskClear(
GUInt32 *mask, std::size_t i)
79 mask[i >> 5] &= ~(0x01 << (i & 0x1f));
88inline void CPLMaskClearAll(
GUInt32 *mask, std::size_t size)
90 auto nBytes = (size + 31) / 8;
91 std::memset(mask, 0, nBytes);
100inline void CPLMaskSet(
GUInt32 *mask, std::size_t i)
102 mask[i >> 5] |= (0x01 << (i & 0x1f));
111inline void CPLMaskSetAll(
GUInt32 *mask, std::size_t size)
113 auto nBytes = (size + 31) / 8;
114 std::memset(mask, 0xff, nBytes);
124inline void CPLMaskMerge(
GUInt32 *mask1,
GUInt32 *mask2, std::size_t n)
126 std::size_t nBytes = (n + 31) / 8;
127 std::size_t nIter = nBytes / 4;
128 for (std::size_t i = 0; i < nIter; i++)
130 mask1[i] |= mask2[i];
Core portability definitions for CPL.
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:177
#define VSI_MALLOC_VERBOSE(size)
VSI_MALLOC_VERBOSE.
Definition cpl_vsi.h:346