MySQL 8.3.0
Source Code Documentation
misc.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2023, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify it under
4the terms of the GNU General Public License, version 2.0, as published by the
5Free Software Foundation.
6
7This program is also distributed with certain software (including but not
8limited to OpenSSL) that is licensed under separate terms, as designated in a
9particular file or component or in included license documentation. The authors
10of MySQL hereby grant you an additional permission to link the program and
11your derivative works with the separately licensed software that they have
12included with MySQL.
13
14This program is distributed in the hope that it will be useful, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
17for more details.
18
19You should have received a copy of the GNU General Public License along with
20this program; if not, write to the Free Software Foundation, Inc.,
2151 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23/** @file storage/temptable/include/temptable/misc.h
24TempTable miscellaneous helper utilities declarations. */
25
26#ifndef TEMPTABLE_MISC_H
27#define TEMPTABLE_MISC_H
28
29#include <cstddef>
30
31#include "my_compiler.h"
32
33#define TEMPTABLE_UNUSED [[maybe_unused]]
34
35#ifdef NDEBUG
36#define TEMPTABLE_UNUSED_NODBUG [[maybe_unused]]
37#else /* NDEBUG */
38#define TEMPTABLE_UNUSED_NODBUG
39#endif /* NDEBUG */
40
41namespace temptable {
42
43/** Check if a given buffer is inside another buffer.
44@return true if inside */
46 /** [in] First buffer, that should be inside the other. */
47 const unsigned char *small,
48 /** [in] First buffer length in bytes. */
49 size_t small_length,
50 /** [in] Second buffer, that should contain the other. */
51 const unsigned char *big,
52 /** [in] Second buffer length in bytes. */
53 size_t big_length) {
54 const unsigned char *small_after_last = small + small_length;
55 const unsigned char *big_after_last = big + big_length;
56
57 return small >= big && small_after_last <= big_after_last;
58}
59
60} /* namespace temptable */
61
62#endif /* TEMPTABLE_MISC_H */
Header for compiler-dependent features.
Definition: allocator.h:44
bool buf_is_inside_another(const unsigned char *small, size_t small_length, const unsigned char *big, size_t big_length)
Check if a given buffer is inside another buffer.
Definition: misc.h:45