libchromeos: Add helpers to work with void pointers

Every time we need to move a void pointer by a specified byte offset,
we need to cast it to char* or something and then add the offset.

These functions help with this void pointer math...

BUG=None
TEST=FEATURES=test emerge-link libchromeos

Change-Id: I9fd70274b3e9dcc395ccfe18d45e5b64469e85c4
Reviewed-on: https://chromium-review.googlesource.com/222854
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/chromeos/pointer_utils.h b/chromeos/pointer_utils.h
new file mode 100644
index 0000000..d431a5d
--- /dev/null
+++ b/chromeos/pointer_utils.h
@@ -0,0 +1,24 @@
+// Copyright 2014 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBCHROMEOS_CHROMEOS_POINTER_UTILS_H_
+#define LIBCHROMEOS_CHROMEOS_POINTER_UTILS_H_
+
+#include <cstdint>
+#include <sys/types.h>
+
+namespace chromeos {
+
+// AdvancePointer() is a helper function to advance void pointer by
+// |byte_offset| bytes. Both const and non-const overloads are provided.
+inline void* AdvancePointer(void* pointer, ssize_t byte_offset) {
+  return reinterpret_cast<uint8_t*>(pointer) + byte_offset;
+}
+inline const void* AdvancePointer(const void* pointer, ssize_t byte_offset) {
+  return reinterpret_cast<const uint8_t*>(pointer) + byte_offset;
+}
+
+}  // namespace chromeos
+
+#endif  // LIBCHROMEOS_CHROMEOS_POINTER_UTILS_H_