Change the access protection on a region of memory starting at the specified address and numBytes long, according to specified mode, making memory readable if (mode & ACCESS_READ) is nonzero and writable if (mode & ACCESS_WRITE) is nonzero. Return 0 on success, and a nonzero value otherwise. The behavior is undefined if addr is not aligned on a page boundary, if numBytes is not a multiple of pageSize(), or if numBytes is 0. Note that some platforms do not support certain protection modes, e.g., on some platforms the memory cannot be made writable but unreadable, or readable but non-executable. On these platforms the actual access protection set on the region might be more permissive than the specified one. Also note that most memory allocators do not expect memory protection on allocated memory to be changed, so you must reset protection back to ACCESS_READ_WRITE before releasing the memory.
Declared in <bdls_memoryutil.h>
static
int
protect(
void* address,
int numBytes,
int mode);