Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Olm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Nheko Reborn
Olm
Commits
030e506c
Commit
030e506c
authored
4 years ago
by
Lukas Lihotzki
Browse files
Options
Downloads
Patches
Plain Diff
use stackAlloc instead of allocate
parent
22f85d3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
javascript/olm_post.js
+10
-5
10 additions, 5 deletions
javascript/olm_post.js
with
10 additions
and
5 deletions
javascript/olm_post.js
+
10
−
5
View file @
030e506c
...
...
@@ -2,12 +2,20 @@ var malloc = Module['_malloc'];
var
free
=
Module
[
'
_free
'
];
var
OLM_ERROR
;
function
filled_stack
(
size
,
filler
)
{
var
ptr
=
stackAlloc
(
size
);
filler
(
new
Uint8Array
(
Module
[
'
HEAPU8
'
].
buffer
,
ptr
,
size
));
return
ptr
;
}
/* allocate a number of bytes of storage on the stack.
*
* If size_or_array is a Number, allocates that number of zero-initialised bytes.
*/
function
stack
(
size_or_array
)
{
return
allocate
(
size_or_array
,
'
i8
'
,
Module
[
'
ALLOC_STACK
'
]);
return
(
typeof
size_or_array
==
'
number
'
)
?
filled_stack
(
size_or_array
,
function
(
x
)
{
x
.
fill
(
0
)
})
:
filled_stack
(
size_or_array
.
length
,
function
(
x
)
{
x
.
set
(
size_or_array
)
});
}
function
array_from_string
(
string
)
{
...
...
@@ -15,10 +23,7 @@ function array_from_string(string) {
}
function
random_stack
(
size
)
{
var
ptr
=
stack
(
size
);
var
array
=
new
Uint8Array
(
Module
[
'
HEAPU8
'
].
buffer
,
ptr
,
size
);
get_random_values
(
array
);
return
ptr
;
return
filled_stack
(
size
,
get_random_values
);
}
function
restore_stack
(
wrapped
)
{
...
...
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