aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/memutils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/utils/memutils.h')
-rw-r--r--src/include/utils/memutils.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
index cd9596ff219..3590c8bad9a 100644
--- a/src/include/utils/memutils.h
+++ b/src/include/utils/memutils.h
@@ -189,4 +189,21 @@ extern MemoryContext BumpContextCreate(MemoryContext parent,
#define SLAB_DEFAULT_BLOCK_SIZE (8 * 1024)
#define SLAB_LARGE_BLOCK_SIZE (8 * 1024 * 1024)
+/*
+ * Test if a memory region starting at "ptr" and of size "len" is full of
+ * zeroes.
+ */
+static inline bool
+pg_memory_is_all_zeros(const void *ptr, size_t len)
+{
+ const char *p = (const char *) ptr;
+
+ for (size_t i = 0; i < len; i++)
+ {
+ if (p[i] != 0)
+ return false;
+ }
+ return true;
+}
+
#endif /* MEMUTILS_H */