MySQL 8.0.31
Source Code Documentation
buf0buddy.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2006, 2022, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/buf0buddy.h
28 Binary buddy allocator for compressed pages
29
30 Created December 2006 by Marko Makela
31 *******************************************************/
32
33#ifndef buf0buddy_h
34#define buf0buddy_h
35
36#include "buf0types.h"
37#include "univ.i"
38
39/** Allocate a block. This function should only be used for allocating
40compressed page frames. The thread calling this function must hold
41buf_pool->LRU_list_mutex and must not hold buf_pool->zip_mutex or any
42block->mutex.
43@param[in,out] buf_pool buffer pool in which the page resides
44@param[in] size compressed page size, between
45 UNIV_ZIP_SIZE_MIN and UNIV_PAGE_SIZE
46@return allocated block, never NULL */
47static inline byte *buf_buddy_alloc(buf_pool_t *buf_pool, ulint size)
48 MY_ATTRIBUTE((malloc));
49
50/** Deallocate a block.
51@param[in,out] buf_pool buffer pool in which the block resides
52@param[in] buf block to be freed, must not be pointed to
53 by the buffer pool
54@param[in] size block size, up to UNIV_PAGE_SIZE */
55static inline void buf_buddy_free(buf_pool_t *buf_pool, void *buf, ulint size);
56
57/** Try to reallocate a block.
58@param[in] buf_pool buffer pool instance
59@param[in] buf block to be reallocated, must be pointed
60to by the buffer pool
61@param[in] size block size, up to UNIV_PAGE_SIZE
62@retval true if succeeded or if failed because the block was fixed
63@retval false if failed because of no free blocks. */
64bool buf_buddy_realloc(buf_pool_t *buf_pool, void *buf, ulint size);
65
66/** Combine all pairs of free buddies.
67@param[in] buf_pool buffer pool instance */
69
70#include "buf0buddy.ic"
71
72#endif /* buf0buddy_h */
bool buf_buddy_realloc(buf_pool_t *buf_pool, void *buf, ulint size)
Try to reallocate a block.
Definition: buf0buddy.cc:704
void buf_buddy_condense_free(buf_pool_t *buf_pool)
Combine all pairs of free buddies.
Definition: buf0buddy.cc:753
static byte * buf_buddy_alloc(buf_pool_t *buf_pool, ulint size)
Allocate a block.
static void buf_buddy_free(buf_pool_t *buf_pool, void *buf, ulint size)
Deallocate a block.
Binary buddy allocator for compressed pages.
The database buffer pool global types for the directory.
#define malloc(A)
Definition: lexyy.cc:914
Definition: buf0block_hint.cc:29
The buffer pool structure.
Definition: buf0buf.h:2152
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:407