MCPcopy Create free account
hub / github.com/apache/arrow / CheckSliceParams

Function CheckSliceParams

cpp/src/arrow/util/slice_util_internal.h:25–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23namespace internal {
24
25static inline Status CheckSliceParams(int64_t object_length, int64_t slice_offset,
26 int64_t slice_length, const char* object_name) {
27 if (ARROW_PREDICT_FALSE(slice_offset < 0)) {
28 return Status::IndexError("Negative ", object_name, " slice offset");
29 }
30 if (ARROW_PREDICT_FALSE(slice_length < 0)) {
31 return Status::IndexError("Negative ", object_name, " slice length");
32 }
33 int64_t offset_plus_length;
34 if (ARROW_PREDICT_FALSE(
35 internal::AddWithOverflow(slice_offset, slice_length, &offset_plus_length))) {
36 return Status::IndexError(object_name, " slice would overflow");
37 }
38 if (ARROW_PREDICT_FALSE(offset_plus_length > object_length)) {
39 return Status::IndexError(object_name, " slice would exceed ", object_name,
40 " length");
41 }
42 return Status::OK();
43}
44
45} // namespace internal
46} // namespace arrow

Callers 3

CheckBufferSliceFunction · 0.85
SliceSafeMethod · 0.85
PutListViewOffsetsFunction · 0.85

Calls 3

IndexErrorFunction · 0.85
AddWithOverflowFunction · 0.85
OKFunction · 0.50

Tested by

no test coverage detected