1 // Copyright 2014 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef LIBBRILLO_BRILLO_POINTER_UTILS_H_
6 #define LIBBRILLO_BRILLO_POINTER_UTILS_H_
7 
8 #include <cstdint>
9 #include <sys/types.h>
10 
11 namespace brillo {
12 
13 // AdvancePointer() is a helper function to advance void pointer by
14 // |byte_offset| bytes. Both const and non-const overloads are provided.
AdvancePointer(void * pointer,ssize_t byte_offset)15 inline void* AdvancePointer(void* pointer, ssize_t byte_offset) {
16   return reinterpret_cast<uint8_t*>(pointer) + byte_offset;
17 }
AdvancePointer(const void * pointer,ssize_t byte_offset)18 inline const void* AdvancePointer(const void* pointer, ssize_t byte_offset) {
19   return reinterpret_cast<const uint8_t*>(pointer) + byte_offset;
20 }
21 
22 }  // namespace brillo
23 
24 #endif  // LIBBRILLO_BRILLO_POINTER_UTILS_H_
25