Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
07d7f05f
Commit
07d7f05f
authored
Dec 07, 2006
by
marko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branches/zip: Add buf_buddy_free() and buf_buddy_free_low().
parent
06746402
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
0 deletions
+102
-0
buf/buf0buddy.c
buf/buf0buddy.c
+54
-0
include/buf0buddy.h
include/buf0buddy.h
+14
-0
include/buf0buddy.ic
include/buf0buddy.ic
+34
-0
No files found.
buf/buf0buddy.c
View file @
07d7f05f
...
...
@@ -51,3 +51,57 @@ buf_buddy_alloc_low(
return
(
bpage
);
}
/**************************************************************************
Release a block to buf_pool->zip_free[]. */
void
*
buf_buddy_free_low
(
/*===============*/
/* out: pointer to the beginning of a block of
size BUF_BUDDY_HIGH that should be freed to
the underlying allocator, or NULL if released
to buf_pool->zip_free[] */
void
*
buf
,
/* in: block to free */
ulint
i
)
/* in: index of buf_pool->zip_free[] */
{
buf_page_t
*
bpage
;
buf_page_t
*
buddy
;
#ifdef UNIV_SYNC_DEBUG
ut_a
(
mutex_own
(
&
buf_pool
->
mutex
));
#endif
/* UNIV_SYNC_DEBUG */
recombine:
ut_ad
(
i
<
BUF_BUDDY_SIZES
);
ut_ad
(
buf
==
ut_align_down
(
buf
,
BUF_BUDDY_LOW
<<
i
));
/* Try to combine adjacent blocks. */
buddy
=
buf_buddy_get
(
buf
,
BUF_BUDDY_LOW
<<
i
);
for
(
bpage
=
UT_LIST_GET_FIRST
(
buf_pool
->
zip_free
[
i
]);
bpage
;
bpage
=
UT_LIST_GET_NEXT
(
list
,
bpage
))
{
if
(
bpage
==
buddy
)
{
/* The buddy is free: recombine */
UT_LIST_REMOVE
(
list
,
buf_pool
->
zip_free
[
i
],
bpage
);
buf
=
ut_align_down
(
buf
,
BUF_BUDDY_LOW
<<
i
);
if
(
++
i
<
BUF_BUDDY_SIZES
)
{
goto
recombine
;
}
/* The whole block is free. */
return
(
buf
);
}
ut_a
(
bpage
!=
buf
);
}
/* Free the block to the buddy list. */
bpage
=
buf
;
bpage
->
state
=
BUF_BLOCK_ZIP_FREE
;
UT_LIST_ADD_FIRST
(
list
,
buf_pool
->
zip_free
[
i
],
bpage
);
return
(
NULL
);
}
include/buf0buddy.h
View file @
07d7f05f
...
...
@@ -52,6 +52,20 @@ buf_buddy_alloc(
FALSE=try to allocate exact size */
__attribute__
((
malloc
));
/**************************************************************************
Release a block to buf_pool->zip_free[]. */
UNIV_INLINE
void
*
buf_buddy_free
(
/*===========*/
/* out: pointer to the beginning of a block of
size BUF_BUDDY_HIGH that should be freed to
the underlying allocator, or NULL if released
to buf_pool->zip_free[] */
void
*
buf
,
/* in: block to free */
ulint
size
)
/* in: block size, up to UNIV_PAGE_SIZE / 2 */
__attribute__
((
nonnull
));
#ifndef UNIV_NONINL
# include "buf0buddy.ic"
#endif
...
...
include/buf0buddy.ic
View file @
07d7f05f
...
...
@@ -27,6 +27,20 @@ buf_buddy_alloc_low(
FALSE=try to allocate exact size */
__attribute__((malloc));
/**************************************************************************
Release a block to buf_pool->zip_free[]. */
void*
buf_buddy_free_low(
/*===============*/
/* out: pointer to the beginning of a block of
size BUF_BUDDY_HIGH that should be freed to
the underlying allocator, or NULL if released
to buf_pool->zip_free[] */
void* buf, /* in: block to free */
ulint i) /* in: index of buf_pool->zip_free[] */
__attribute__((nonnull));
/**************************************************************************
Get the offset of the buddy of a compressed page frame. */
UNIV_INLINE
...
...
@@ -83,6 +97,26 @@ buf_buddy_alloc(
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), split));
}
/**************************************************************************
Release a block to buf_pool->zip_free[]. */
UNIV_INLINE
void*
buf_buddy_free(
/*===========*/
/* out: pointer to the beginning of a block of
size BUF_BUDDY_HIGH that should be freed to
the underlying allocator, or NULL if released
to buf_pool->zip_free[] */
void* buf, /* in: block to free */
ulint size) /* in: block size, up to UNIV_PAGE_SIZE / 2 */
{
#ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex));
#endif /* UNIV_SYNC_DEBUG */
return(buf_buddy_free_low(buf, buf_buddy_get_slot(size)));
}
#ifdef UNIV_MATERIALIZE
# undef UNIV_INLINE
# define UNIV_INLINE UNIV_INLINE_ORIGINAL
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment