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