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