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