summaryrefslogtreecommitdiff
path: root/chromeos/pointer_utils.h
blob: d431a5d392b699c6cf4db717089e044a67a12220 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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_