aboutsummaryrefslogtreecommitdiff
path: root/pattern.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-05-30 16:55:22 +0200
committerBen Harris <bjh21@bjh21.me.uk>2023-05-30 17:00:31 +0200
commit5acce15ed907d29a5575668a09e7d94cf7a36b3f (patch)
treec203470627c002ca3bbb609be5e8f2f0036f9416 /pattern.c
parent6a41c0b7a0c0f8299a86e5d33e7008ced3911924 (diff)
downloadpuzzles-5acce15ed907d29a5575668a09e7d94cf7a36b3f.zip
puzzles-5acce15ed907d29a5575668a09e7d94cf7a36b3f.tar.gz
puzzles-5acce15ed907d29a5575668a09e7d94cf7a36b3f.tar.bz2
puzzles-5acce15ed907d29a5575668a09e7d94cf7a36b3f.tar.xz
js: pass preferences file from JS to C on the heap, not the stack
The C stack used by Emscripten is quite small, so passing more than a few klilobytes of data on it tends to cause an overflow. Current versions of puzzles will only generate tiny preferences files, but this might change in future and in any case Puzzles shouldn't crash just because the preferences in local storage have got corrupted. To fix this, we now have JavaScript allocate a suitable amount of C heap memory using malloc() and stick the preferences file in there. This could plausibly fail if the preferences file were really big, but that's unlikely since browsers generally limit an origin to about 5 MB of local storage. In any case, if malloc() does fail, we'll just ignore the preferences file, which is probably the right thing to do.
Diffstat (limited to 'pattern.c')
0 files changed, 0 insertions, 0 deletions