Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
297360ef
Commit
297360ef
authored
Nov 01, 2013
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rst: Switch shmalloc allocator to use rst-malloc
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
c9aaf9f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
33 deletions
+3
-33
util.c
util.c
+3
-33
No files found.
util.c
View file @
297360ef
...
...
@@ -35,6 +35,7 @@
#include "asm/types.h"
#include "list.h"
#include "util.h"
#include "rst-malloc.h"
#include "crtools.h"
...
...
@@ -434,46 +435,15 @@ int is_anon_link_type(int lfd, char *type)
return
!
strcmp
(
link
,
aux
);
}
static
void
*
sh_buf
;
static
unsigned
int
sh_bytes_left
;
static
size_t
sh_last_size
;
#define SH_BUF_CHUNK 4096
void
*
shmalloc
(
size_t
bytes
)
{
void
*
ret
;
if
(
bytes
>
SH_BUF_CHUNK
)
{
pr_err
(
"Too big shared buffer requested %zu
\n
"
,
bytes
);
return
NULL
;
}
if
(
sh_bytes_left
<
bytes
)
{
sh_buf
=
mmap
(
NULL
,
SH_BUF_CHUNK
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
|
MAP_ANON
,
0
,
0
);
if
(
sh_buf
==
MAP_FAILED
)
{
pr_perror
(
"Can't alloc shared buffer"
);
return
NULL
;
}
sh_bytes_left
=
SH_BUF_CHUNK
;
}
ret
=
sh_buf
;
sh_buf
+=
bytes
;
sh_bytes_left
-=
bytes
;
sh_last_size
=
bytes
;
return
ret
;
return
rst_mem_alloc
(
bytes
,
RM_SHARED
);
}
/* Only last chunk can be released */
void
shfree_last
(
void
*
ptr
)
{
BUG_ON
(
sh_buf
-
sh_last_size
!=
ptr
);
sh_buf
-=
sh_last_size
;
sh_bytes_left
+=
sh_last_size
;
sh_last_size
=
0
;
rst_mem_free_last
(
RM_SHARED
);
}
int
run_scripts
(
char
*
action
)
...
...
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