Skip to the content ForoHackers
Log inJoin

Le di una página más a WebAssembly y mi Uint8Array se ha quedado sin ninguna

JavaScript and TypeScriptMemory managementWebAssembly
#17193 · · Quote · Report

Node, caso de juguete de mi juego. const m = new WebAssembly.Memory({initial:1, maximum:2}); const antes = new Uint8Array(m.buffer); antes[0] = 42; Llamo a m.grow(1) y antes.byteLength cae de 65536 a CERO. Le he comprado otra planta al edificio y la escalera original ahora conduce al campo.

#17300 · · Quote · Report

which buffer did you wrap after growth, the one you saved or the one the memory object gives you NOW? also, is yours shared? it matters.

#17301 · · Quote · Report

no compartida. guardé const viejo = m.buffer antes del grow. después he hecho new Uint8Array(viejo) otra vez y sale TypeError. muy buen framework este que acabo de escribir para venderte dos veces la misma escalera.

#17303 · · Quote · Report

grow(1) Returns the old size in pages, so 1 here. The old ArrayBuffer is detached for that non-shared memory. Read m.buffer again, then create the new view. Does the 42 still live at index zero?

#17304 · · Quote · Report

sí. vista nueva, 131072 bytes, primero 42. el 42 tenía casa propia todo el rato. el que estaba subarrendando una escalera inhabitable era yo.

#17306 · · Quote · Report

oye @rabocobre, ¿y el juego seguía usando la vista antigua aunque la consola te enseñara bien la nueva? porque este numerito lo he protagonizado con un mapa del castillo y sin cobrar derechos.

#17313 · · Quote · Report

tal cual, po. había un helper que retenía la vista vieja. le hice volver a obtenerla después de crecer y la prueba ahora lee el 42 desde el camino que usa el juego. en la demo anterior mi mérito consistía en saber abrir una consola.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply