Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
9f5d7b07
Commit
9f5d7b07
authored
10 months ago
by
Jason Volk
Committed by
🥺
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix mallctl suite lints
Signed-off-by:
Jason Volk
<
jason@zemos.net
>
parent
4faf690f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/alloc/je.rs
+9
-2
9 additions, 2 deletions
src/alloc/je.rs
with
9 additions
and
2 deletions
src/alloc/je.rs
+
9
−
2
View file @
9f5d7b07
...
...
@@ -21,14 +21,17 @@ pub(crate) fn memory_usage() -> String {
)
}
#[allow(clippy::ptr_as_ptr)]
pub
(
crate
)
fn
memory_stats
()
->
String
{
const
MAX_LENGTH
:
usize
=
65536
-
4096
;
let
opts_s
=
"d"
;
let
mut
str
:
String
=
String
::
new
();
let
mut
str
=
String
::
new
();
let
opaque
:
*
mut
c_void
=
&
mut
str
as
*
mut
_
as
*
mut
c_void
;
let
opts_p
:
*
const
c_char
=
std
::
ffi
::
CString
::
new
(
opts_s
)
.expect
(
"cstring"
)
.into_raw
()
as
*
const
c_char
;
// SAFETY: calls malloc_stats_print() with our string instance which must remain in this frame.
unsafe
{
ffi
::
malloc_stats_print
(
Some
(
malloc_stats_cb
),
opaque
,
opts_p
)
};
str
.truncate
(
MAX_LENGTH
);
...
...
@@ -36,8 +39,12 @@ pub(crate) fn memory_stats() -> String {
}
extern
"C"
fn
malloc_stats_cb
(
opaque
:
*
mut
c_void
,
msg
:
*
const
c_char
)
{
let
res
:
&
mut
String
=
unsafe
{
std
::
mem
::
transmute
::
<*
mut
c_void
,
&
mut
String
>
(
opaque
)
};
// SAFETY: we have to trust the opaque points to our String
let
res
:
&
mut
String
=
unsafe
{
&
mut
*
opaque
.cast
::
<
String
>
()
};
// SAFETY: we have to trust the string is null terminated.
let
msg
=
unsafe
{
std
::
ffi
::
CStr
::
from_ptr
(
msg
)
};
let
msg
=
String
::
from_utf8_lossy
(
msg
.to_bytes
());
res
.push_str
(
msg
.as_ref
());
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment