You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move writeStringToMemory/writeAsciiToMemory to library_legacy.js (#19103)
`writeStringToMemory` was already marked as deprecated.
We have `stringToAscii` and `stringToUTF8` which we recommend over these
function.
Also, change `stringToUTF8Array` to `stringToUTF8` in a couple of places
here the target is `HEAPU8`.
Writes a JavaScript string to a specified address in the heap.
259
-
260
-
.. warning:: This function is deprecated, you should call the function ``stringToUTF8`` instead, which provides a secure bounded version of the same functionality instead.
261
-
262
-
.. code-block:: javascript
263
-
264
-
// Allocate space for string and extra '0' at the end
265
-
var buffer =Module._malloc(myString.length+1);
266
-
267
-
// Write the string to memory
268
-
Module.writeStringToMemory(myString, buffer);
269
-
270
-
// We can now send buffer into a C function, it is just a normal char* pointer
271
-
272
-
:param string: The string to write into memory.
273
-
:type string: String
274
-
:param buffer: The address (number) where ``string`` is to be written.
275
-
:type buffer: Number
276
-
:param dontAddNull: If ``true``, the new array is not zero-terminated.
277
-
:type dontAddNull: bool
278
-
279
-
280
-
281
255
.. js:function::writeArrayToMemory(array, buffer)
282
256
283
257
Writes an array to a specified address in the heap. Note that memory should to be allocated for the array before it is written.
Writes an ASCII string to a specified address in the heap. Note that memory should to be allocated for the string before it is written.
294
-
295
-
The string is assumed to only have characters in the ASCII character set. If ASSERTIONS are enabled and this is not the case, it will fail.
296
-
297
-
.. code-block:: javascript
298
-
299
-
// Allocate space for string
300
-
var buffer =Module._malloc(myString.length);
301
-
302
-
// Write the string to memory
303
-
Module.writeStringToMemory(myString, buffer);
304
-
305
-
:param string: The string to write into memory.
306
-
:param buffer: The address where ``string`` is to be written.
307
-
:param dontAddNull: If ``true``, the new string is not zero-terminated.
308
-
:type dontAddNull: bool
309
-
310
-
311
-
312
265
Run dependencies
313
-
=====================================
266
+
================
314
267
315
268
Note that generally run dependencies are managed by the file packager and other parts of the system. It is rare for developers to use this API directly.
316
269
@@ -338,7 +291,7 @@ Note that generally run dependencies are managed by the file packager and other
0 commit comments