Skip to content

Commit 878ee3f

Browse files
committed
fix
1 parent 80fb450 commit 878ee3f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

std/assembly/internal/runtime.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class HEADER {
1414
}
1515

1616
/** Size of the common runtime header. */
17-
@inline export const HEADER_SIZE: usize = (offsetof<ArrayBuffer>() + AL_MASK) & ~AL_MASK;
17+
@inline export const HEADER_SIZE: usize = (offsetof<HEADER>() + AL_MASK) & ~AL_MASK;
1818
/** Magic value used to validate common headers. */
1919
@inline export const HEADER_MAGIC: usize = <usize>0xA55E4B17;
2020

@@ -131,7 +131,7 @@ export function REGISTER<T>(ref: usize): void {
131131
// === String =====================================================================================
132132

133133
/** Size of a string header, excl. common runtime header. */
134-
@inline export const STRING_HEADER_SIZE: usize = (offsetof<String>() + AL_MASK) & ~AL_MASK;
134+
@inline export const STRING_HEADER_SIZE: usize = (offsetof<String>() + 1) & ~1; // 2 byte aligned
135135

136136
/** Allocates a new String and returns a pointer to it. */
137137
@inline export function ALLOC_STRING(length: u32): String {
@@ -142,3 +142,5 @@ export function REGISTER<T>(ref: usize): void {
142142
@inline export function REALLOC_STRING(ref: usize, length: u32): String {
143143
return changetype<String>(REALLOC(ref, STRING_HEADER_SIZE + (length << 1)));
144144
}
145+
146+
// ...

0 commit comments

Comments
 (0)