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
3e827e8d
Commit
3e827e8d
authored
Nov 28, 2007
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addresses #8
git-svn-id:
file:///svn/tokudb@807
c7de825b-a66e-492c-adef-691d508d4ae1
parent
d8ecabcb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
28 deletions
+28
-28
newbrt/mempool.c
newbrt/mempool.c
+9
-9
newbrt/mempool.h
newbrt/mempool.h
+10
-10
newbrt/pma.c
newbrt/pma.c
+9
-9
No files found.
newbrt/mempool.c
View file @
3e827e8d
...
...
@@ -2,7 +2,7 @@
#include <assert.h>
#include "mempool.h"
void
mempool_init
(
struct
mempool
*
mp
,
void
*
base
,
int
size
)
{
void
toku_
mempool_init
(
struct
mempool
*
mp
,
void
*
base
,
int
size
)
{
// printf("mempool_init %p %p %d\n", mp, base, size);
assert
(
base
!=
0
&&
size
>=
0
);
mp
->
base
=
base
;
...
...
@@ -13,32 +13,32 @@ void mempool_init(struct mempool *mp, void *base, int size) {
mp
->
compress_arg
=
0
;
}
void
mempool_fini
(
struct
mempool
*
mp
__attribute__
((
unused
)))
{
void
toku_
mempool_fini
(
struct
mempool
*
mp
__attribute__
((
unused
)))
{
// printf("mempool_fini %p %p %d %d\n", mp, mp->base, mp->size, mp->frag_size);
}
void
mempool_set_compress_func
(
struct
mempool
*
mp
,
mempool_compress_func
compress_func
,
void
*
compress_arg
)
{
void
toku_
mempool_set_compress_func
(
struct
mempool
*
mp
,
mempool_compress_func
compress_func
,
void
*
compress_arg
)
{
mp
->
compress_func
=
compress_func
;
mp
->
compress_arg
=
compress_arg
;
}
void
mempool_call_compress_func
(
struct
mempool
*
mp
)
{
void
toku_
mempool_call_compress_func
(
struct
mempool
*
mp
)
{
mp
->
compress_func
(
mp
,
mp
->
compress_arg
);
}
void
*
mempool_get_base
(
struct
mempool
*
mp
)
{
void
*
toku_
mempool_get_base
(
struct
mempool
*
mp
)
{
return
mp
->
base
;
}
int
mempool_get_size
(
struct
mempool
*
mp
)
{
int
toku_
mempool_get_size
(
struct
mempool
*
mp
)
{
return
mp
->
size
;
}
int
mempool_get_frag_size
(
struct
mempool
*
mp
)
{
int
toku_
mempool_get_frag_size
(
struct
mempool
*
mp
)
{
return
mp
->
frag_size
;
}
void
*
mempool_malloc
(
struct
mempool
*
mp
,
int
size
,
int
alignment
)
{
void
*
toku_
mempool_malloc
(
struct
mempool
*
mp
,
int
size
,
int
alignment
)
{
assert
(
mp
->
free_offset
<=
mp
->
size
);
void
*
vp
;
int
offset
=
(
mp
->
free_offset
+
(
alignment
-
1
))
&
~
(
alignment
-
1
);
...
...
@@ -54,7 +54,7 @@ void *mempool_malloc(struct mempool *mp, int size, int alignment) {
return
vp
;
}
void
mempool_mfree
(
struct
mempool
*
mp
,
void
*
vp
,
int
size
)
{
void
toku_
mempool_mfree
(
struct
mempool
*
mp
,
void
*
vp
,
int
size
)
{
assert
(
size
>=
0
&&
mp
->
base
<=
vp
&&
vp
+
size
<=
mp
->
base
+
mp
->
size
);
mp
->
frag_size
+=
size
;
assert
(
mp
->
frag_size
<=
mp
->
size
);
...
...
newbrt/mempool.h
View file @
3e827e8d
...
...
@@ -21,33 +21,33 @@ struct mempool {
/* initialize the memory pool with the base address and size of a
contiguous chunk of memory */
void
mempool_init
(
struct
mempool
*
mp
,
void
*
base
,
int
size
);
void
toku_
mempool_init
(
struct
mempool
*
mp
,
void
*
base
,
int
size
);
/* finalize the memory pool */
void
mempool_fini
(
struct
mempool
*
mp
);
void
toku_
mempool_fini
(
struct
mempool
*
mp
);
void
mempool_set_compress_func
(
struct
mempool
*
mp
,
mempool_compress_func
compress_func
,
void
*
compress_arg
);
void
toku_
mempool_set_compress_func
(
struct
mempool
*
mp
,
mempool_compress_func
compress_func
,
void
*
compress_arg
);
void
mempool_call_compress_func
(
struct
mempool
*
mp
);
void
toku_
mempool_call_compress_func
(
struct
mempool
*
mp
);
/* get the base address of the memory pool */
void
*
mempool_get_base
(
struct
mempool
*
mp
);
void
*
toku_
mempool_get_base
(
struct
mempool
*
mp
);
/* get the size of the memory pool */
int
mempool_get_size
(
struct
mempool
*
mp
);
int
toku_
mempool_get_size
(
struct
mempool
*
mp
);
/* get the amount of fragmented space in the memory pool */
int
mempool_get_frag_size
(
struct
mempool
*
mp
);
int
toku_
mempool_get_frag_size
(
struct
mempool
*
mp
);
/* allocate a chunk of memory from the memory pool suitably aligned */
void
*
mempool_malloc
(
struct
mempool
*
mp
,
int
size
,
int
alignment
);
void
*
toku_
mempool_malloc
(
struct
mempool
*
mp
,
int
size
,
int
alignment
);
/* free a previously allocated chunk of memory. the free only updates
a count of the amount of free space in the memory pool. the memory
pool does not keep track of the locations of the free chunks */
void
mempool_mfree
(
struct
mempool
*
mp
,
void
*
vp
,
int
size
);
void
toku_
mempool_mfree
(
struct
mempool
*
mp
,
void
*
vp
,
int
size
);
static
inline
int
mempool_inrange
(
struct
mempool
*
mp
,
void
*
vp
,
int
size
)
{
static
inline
int
toku_
mempool_inrange
(
struct
mempool
*
mp
,
void
*
vp
,
int
size
)
{
return
mp
->
base
<=
vp
&&
vp
+
size
<=
mp
->
base
+
mp
->
size
;
}
...
...
newbrt/pma.c
View file @
3e827e8d
...
...
@@ -104,7 +104,7 @@ struct kv_pair_tag {
/* allocate a kv pair from the pma kv memory pool */
static
struct
kv_pair
*
kv_pair_malloc_mempool
(
void
*
key
,
int
keylen
,
void
*
val
,
int
vallen
,
struct
mempool
*
mp
)
{
struct
kv_pair
*
kv
=
mempool_malloc
(
mp
,
sizeof
(
struct
kv_pair
)
+
keylen
+
vallen
,
4
);
struct
kv_pair
*
kv
=
toku_
mempool_malloc
(
mp
,
sizeof
(
struct
kv_pair
)
+
keylen
+
vallen
,
4
);
if
(
kv
)
kv_pair_init
(
kv
,
key
,
keylen
,
val
,
vallen
);
return
kv
;
...
...
@@ -113,19 +113,19 @@ static struct kv_pair *kv_pair_malloc_mempool(void *key, int keylen, void *val,
/* compress all of the kv pairs to the left edge of the memory pool and
update the pma index with the new kv pair locations */
static
int
pma_compress_kvspace
(
PMA
pma
)
{
if
(
mempool_get_frag_size
(
&
pma
->
kvspace
)
==
0
)
if
(
toku_
mempool_get_frag_size
(
&
pma
->
kvspace
)
==
0
)
return
-
1
;
void
*
mp
=
toku_malloc
(
pma
->
kvspace
.
size
);
if
(
mp
==
0
)
return
-
2
;
struct
mempool
new_kvspace
;
mempool_init
(
&
new_kvspace
,
mp
,
pma
->
kvspace
.
size
);
toku_
mempool_init
(
&
new_kvspace
,
mp
,
pma
->
kvspace
.
size
);
int
i
;
for
(
i
=
0
;
i
<
pma
->
N
;
i
++
)
{
struct
kv_pair
*
kv
=
pma
->
pairs
[
i
];
if
(
kv_pair_inuse
(
kv
))
{
kv
=
kv_pair_ptr
(
kv
);
struct
kv_pair
*
newkv
=
mempool_malloc
(
&
new_kvspace
,
kv_pair_size
(
kv
),
4
);
struct
kv_pair
*
newkv
=
toku_
mempool_malloc
(
&
new_kvspace
,
kv_pair_size
(
kv
),
4
);
assert
(
newkv
);
memcpy
(
newkv
,
kv
,
kv_pair_size
(
kv
));
if
(
kv_pair_deleted
(
pma
->
pairs
[
i
]))
...
...
@@ -158,7 +158,7 @@ static struct kv_pair *pma_malloc_kv_pair(PMA pma __attribute__((unused)), void
static
void
pma_mfree_kv_pair
(
PMA
pma
__attribute__
((
unused
)),
struct
kv_pair
*
kv
)
{
kv
=
kv_pair_ptr
(
kv
);
#if PMA_USE_MEMPOOL
mempool_mfree
(
&
pma
->
kvspace
,
kv
,
kv_pair_size
(
kv
));
toku_
mempool_mfree
(
&
pma
->
kvspace
,
kv
,
kv_pair_size
(
kv
));
#else
kv_pair_free
(
kv
);
#endif
...
...
@@ -609,7 +609,7 @@ int toku_pma_create(PMA *pma, pma_compare_fun_t compare_fun, DB *db, FILENUM fil
maxsize
=
maxsize
+
maxsize
/
4
;
#if PMA_USE_MEMPOOL
void
*
mpbase
=
toku_malloc
(
maxsize
);
assert
(
mpbase
);
mempool_init
(
&
result
->
kvspace
,
mpbase
,
maxsize
);
toku_
mempool_init
(
&
result
->
kvspace
,
mpbase
,
maxsize
);
#endif
*
pma
=
result
;
assert
((
unsigned
long
)
result
->
pairs
[
result
->
N
]
==
0xdeadbeefL
);
...
...
@@ -961,8 +961,8 @@ int toku_pma_free (PMA *pmap) {
}
assert
(
pma
->
n_pairs_present
==
0
);
#if PMA_USE_MEMPOOL
void
*
mpbase
=
mempool_get_base
(
&
pma
->
kvspace
);
mempool_fini
(
&
pma
->
kvspace
);
void
*
mpbase
=
toku_
mempool_get_base
(
&
pma
->
kvspace
);
toku_
mempool_fini
(
&
pma
->
kvspace
);
toku_free
(
mpbase
);
#endif
toku_free
(
pma
->
pairs
);
...
...
@@ -1582,7 +1582,7 @@ void toku_pma_verify(PMA pma) {
kv
=
pma
->
pairs
[
i
];
if
(
kv_pair_inuse
(
kv
))
{
kv
=
kv_pair_ptr
(
kv
);
assert
(
mempool_inrange
(
&
pma
->
kvspace
,
kv
,
kv_pair_size
(
kv
)));
assert
(
toku_
mempool_inrange
(
&
pma
->
kvspace
,
kv
,
kv_pair_size
(
kv
)));
}
}
#endif
...
...
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