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
446ad272
Commit
446ad272
authored
Apr 13, 2002
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
collision resolving
parents
e5866a7a
8dc64567
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
45 deletions
+49
-45
include/my_alloc.h
include/my_alloc.h
+39
-0
include/my_sys.h
include/my_sys.h
+1
-20
include/mysql.h
include/mysql.h
+1
-17
mysys/my_alloc.c
mysys/my_alloc.c
+8
-8
No files found.
include/my_alloc.h
0 → 100644
View file @
446ad272
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Data structures for mysys/my_alloc.c (root memory allocator)
*/
#ifndef ST_USED_MEM_DEFINED
#define ST_USED_MEM_DEFINED
typedef
struct
st_used_mem
{
/* struct for once_alloc (block) */
struct
st_used_mem
*
next
;
/* Next block in use */
unsigned
int
left
;
/* memory left in block */
unsigned
int
size
;
/* size of block */
}
USED_MEM
;
typedef
struct
st_mem_root
{
USED_MEM
*
free
;
/* blocks with free memory in it */
USED_MEM
*
used
;
/* blocks almost without free memory */
USED_MEM
*
pre_alloc
;
/* preallocated block */
/* if block have less memory it will be put in 'used' list*/
unsigned
int
min_malloc
;
unsigned
int
block_size
;
/* initial block size */
unsigned
int
block_num
;
/* allocated blocks counter */
void
(
*
error_handler
)(
void
);
}
MEM_ROOT
;
#endif
include/my_sys.h
View file @
446ad272
...
@@ -464,26 +464,7 @@ typedef struct st_changeable_var {
...
@@ -464,26 +464,7 @@ typedef struct st_changeable_var {
}
CHANGEABLE_VAR
;
}
CHANGEABLE_VAR
;
/* structs for alloc_root */
#include "my_alloc.h"
#ifndef ST_USED_MEM_DEFINED
#define ST_USED_MEM_DEFINED
typedef
struct
st_used_mem
{
/* struct for once_alloc */
struct
st_used_mem
*
next
;
/* Next block in use */
unsigned
int
left
;
/* memory left in block */
unsigned
int
size
;
/* Size of block */
}
USED_MEM
;
typedef
struct
st_mem_root
{
USED_MEM
*
free
;
USED_MEM
*
used
;
USED_MEM
*
pre_alloc
;
unsigned
int
min_malloc
;
unsigned
int
block_size
;
void
(
*
error_handler
)(
void
);
}
MEM_ROOT
;
#endif
/* Prototypes for mysys and my_func functions */
/* Prototypes for mysys and my_func functions */
...
...
include/mysql.h
View file @
446ad272
...
@@ -100,23 +100,7 @@ typedef struct st_mysql_rows {
...
@@ -100,23 +100,7 @@ typedef struct st_mysql_rows {
typedef
MYSQL_ROWS
*
MYSQL_ROW_OFFSET
;
/* offset to current row */
typedef
MYSQL_ROWS
*
MYSQL_ROW_OFFSET
;
/* offset to current row */
#ifndef ST_USED_MEM_DEFINED
#include "my_alloc.h"
#define ST_USED_MEM_DEFINED
typedef
struct
st_used_mem
{
/* struct for once_alloc */
struct
st_used_mem
*
next
;
/* Next block in use */
unsigned
int
left
;
/* memory left in block */
unsigned
int
size
;
/* size of block */
}
USED_MEM
;
typedef
struct
st_mem_root
{
USED_MEM
*
free
;
USED_MEM
*
used
;
USED_MEM
*
pre_alloc
;
unsigned
int
min_malloc
;
unsigned
int
block_size
;
void
(
*
error_handler
)(
void
);
}
MEM_ROOT
;
#endif
typedef
struct
st_mysql_data
{
typedef
struct
st_mysql_data
{
my_ulonglong
rows
;
my_ulonglong
rows
;
...
...
mysys/my_alloc.c
View file @
446ad272
...
@@ -29,6 +29,7 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
...
@@ -29,6 +29,7 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
mem_root
->
min_malloc
=
32
;
mem_root
->
min_malloc
=
32
;
mem_root
->
block_size
=
block_size
-
MALLOC_OVERHEAD
-
sizeof
(
USED_MEM
)
-
8
;
mem_root
->
block_size
=
block_size
-
MALLOC_OVERHEAD
-
sizeof
(
USED_MEM
)
-
8
;
mem_root
->
error_handler
=
0
;
mem_root
->
error_handler
=
0
;
mem_root
->
block_num
=
0
;
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
if
(
pre_alloc_size
)
if
(
pre_alloc_size
)
{
{
...
@@ -61,25 +62,20 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
...
@@ -61,25 +62,20 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
mem_root
->
used
=
next
;
mem_root
->
used
=
next
;
return
(
gptr
)
(((
char
*
)
next
)
+
ALIGN_SIZE
(
sizeof
(
USED_MEM
)));
return
(
gptr
)
(((
char
*
)
next
)
+
ALIGN_SIZE
(
sizeof
(
USED_MEM
)));
#else
#else
uint
get_size
,
max_left
;
uint
get_size
,
block_size
;
gptr
point
;
gptr
point
;
reg1
USED_MEM
*
next
;
reg1
USED_MEM
*
next
;
reg2
USED_MEM
**
prev
;
reg2
USED_MEM
**
prev
;
Size
=
ALIGN_SIZE
(
Size
);
Size
=
ALIGN_SIZE
(
Size
);
prev
=
&
mem_root
->
free
;
prev
=
&
mem_root
->
free
;
max_left
=
0
;
for
(
next
=
*
prev
;
next
&&
next
->
left
<
Size
;
next
=
next
->
next
)
for
(
next
=
*
prev
;
next
&&
next
->
left
<
Size
;
next
=
next
->
next
)
{
if
(
next
->
left
>
max_left
)
max_left
=
next
->
left
;
prev
=
&
next
->
next
;
prev
=
&
next
->
next
;
}
if
(
!
next
)
if
(
!
next
)
{
/* Time to alloc new block */
{
/* Time to alloc new block */
block_size
=
mem_root
->
block_size
*
((
mem_root
->
block_num
>>
2
)
+
1
);
get_size
=
Size
+
ALIGN_SIZE
(
sizeof
(
USED_MEM
));
get_size
=
Size
+
ALIGN_SIZE
(
sizeof
(
USED_MEM
));
if
(
max_left
*
4
<
mem_root
->
block_size
&&
get_size
<
mem_root
->
block_size
)
get_size
=
max
(
get_size
,
block_size
);
get_size
=
mem_root
->
block_size
;
/* Normal alloc */
if
(
!
(
next
=
(
USED_MEM
*
)
my_malloc
(
get_size
,
MYF
(
MY_WME
))))
if
(
!
(
next
=
(
USED_MEM
*
)
my_malloc
(
get_size
,
MYF
(
MY_WME
))))
{
{
...
@@ -87,6 +83,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
...
@@ -87,6 +83,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
(
*
mem_root
->
error_handler
)();
(
*
mem_root
->
error_handler
)();
return
((
gptr
)
0
);
/* purecov: inspected */
return
((
gptr
)
0
);
/* purecov: inspected */
}
}
mem_root
->
block_num
++
;
next
->
next
=
*
prev
;
next
->
next
=
*
prev
;
next
->
size
=
get_size
;
next
->
size
=
get_size
;
next
->
left
=
get_size
-
ALIGN_SIZE
(
sizeof
(
USED_MEM
));
next
->
left
=
get_size
-
ALIGN_SIZE
(
sizeof
(
USED_MEM
));
...
@@ -165,7 +162,10 @@ void free_root(MEM_ROOT *root, myf MyFlags)
...
@@ -165,7 +162,10 @@ void free_root(MEM_ROOT *root, myf MyFlags)
root
->
free
=
root
->
pre_alloc
;
root
->
free
=
root
->
pre_alloc
;
root
->
free
->
left
=
root
->
pre_alloc
->
size
-
ALIGN_SIZE
(
sizeof
(
USED_MEM
));
root
->
free
->
left
=
root
->
pre_alloc
->
size
-
ALIGN_SIZE
(
sizeof
(
USED_MEM
));
root
->
free
->
next
=
0
;
root
->
free
->
next
=
0
;
root
->
block_num
=
1
;
}
}
else
root
->
block_num
=
0
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
...
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