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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
449de0f4
Commit
449de0f4
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
12682d42
Changes
3
Show 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 @
449de0f4
...
@@ -51,3 +51,57 @@ buf_buddy_alloc_low(
...
@@ -51,3 +51,57 @@ buf_buddy_alloc_low(
return
(
bpage
);
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 @
449de0f4
...
@@ -52,6 +52,20 @@ buf_buddy_alloc(
...
@@ -52,6 +52,20 @@ buf_buddy_alloc(
FALSE=try to allocate exact size */
FALSE=try to allocate exact size */
__attribute__
((
malloc
));
__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
#ifndef UNIV_NONINL
# include "buf0buddy.ic"
# include "buf0buddy.ic"
#endif
#endif
...
...
include/buf0buddy.ic
View file @
449de0f4
...
@@ -27,6 +27,20 @@ buf_buddy_alloc_low(
...
@@ -27,6 +27,20 @@ buf_buddy_alloc_low(
FALSE=try to allocate exact size */
FALSE=try to allocate exact size */
__attribute__((malloc));
__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. */
Get the offset of the buddy of a compressed page frame. */
UNIV_INLINE
UNIV_INLINE
...
@@ -83,6 +97,26 @@ buf_buddy_alloc(
...
@@ -83,6 +97,26 @@ buf_buddy_alloc(
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), split));
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
#ifdef UNIV_MATERIALIZE
# undef UNIV_INLINE
# undef UNIV_INLINE
# define UNIV_INLINE UNIV_INLINE_ORIGINAL
# 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