| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2006, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 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 |
| 41 |
compressed page frames. The thread calling this function must hold |
| 42 |
buf_pool->LRU_list_mutex and must not hold buf_pool->zip_mutex or any |
| 43 |
block->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 */ |
| 48 |
static 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 */ |
| 56 |
static 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 |
| 61 |
to 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. */ |
| 65 |
bool 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 */ |
| 69 |
void buf_buddy_condense_free(buf_pool_t *buf_pool); |
| 70 |
|
| 71 |
#include "buf0buddy.ic" |
| 72 |
|
| 73 |
#endif /* buf0buddy_h */ |