Skip to content

Commit cd1aacc

Browse files
authored
Rename allocateUTF8OnStack -> stringToNewUTF8OnStack (#19092)
The old name is still available as an alias in library_legacy.js. Followup to #19089
1 parent 2a13190 commit cd1aacc

18 files changed

+44
-42
lines changed

ChangeLog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ See docs/process.md for more on how version tagging works.
2323
- `FS.loadFilesFromDB` and `FS.saveFilesToDB` were removed. We think it's
2424
unlikly there were any users of these functions since there is now a separate
2525
IDBFS filesystem for folks that want persistence. (#19049)
26-
- `allocateUTF8` library function moved to `library_legacy.js`. Prefer the
27-
more accurately named `stringToNewUTF8`.
26+
- `allocateUTF8` and `allocateUTF8OnStack` library function moved to
27+
`library_legacy.js`. Prefer the more accurately named `stringToNewUTF8` and
28+
`stringToUTF8OnStack`. (#19089)
2829
- `SDL_image` port was updated to version 2.6.0.
2930
- `-z` arguments are now passed directly to wasm-ld without the need for the
3031
`-Wl,` prefix. This matches the behaviour of both clang and gcc. (#18956)

emscripten.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def update_settings_glue(wasm_file, metadata):
157157
settings.MAIN_READS_PARAMS = metadata.mainReadsParams or bool(settings.MAIN_MODULE)
158158
if settings.MAIN_READS_PARAMS and not settings.STANDALONE_WASM:
159159
# callMain depends on this library function
160-
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$allocateUTF8OnStack']
160+
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$stringToUTF8OnStack']
161161

162162
if settings.STACK_OVERFLOW_CHECK and not settings.SIDE_MODULE:
163163
# writeStackCookie and checkStackCookie both rely on emscripten_stack_get_end being

src/library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3713,7 +3713,7 @@ DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.push(
37133713
'$stringToUTF32',
37143714
'$lengthBytesUTF32',
37153715
'$stringToNewUTF8',
3716-
'$allocateUTF8OnStack',
3716+
'$stringToUTF8OnStack',
37173717
'$writeStringToMemory',
37183718
'$writeArrayToMemory',
37193719
'$writeAsciiToMemory',

src/library_ccall.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mergeInto(LibraryManager.library, {
1515
},
1616

1717
// C calling interface.
18-
$ccall__deps: ['$getCFunc', '$writeArrayToMemory', '$allocateUTF8OnStack'],
18+
$ccall__deps: ['$getCFunc', '$writeArrayToMemory', '$stringToUTF8OnStack'],
1919
$ccall__docs: `
2020
/**
2121
* @param {string|null=} returnType
@@ -33,7 +33,7 @@ mergeInto(LibraryManager.library, {
3333
var ret = 0;
3434
if (str !== null && str !== undefined && str !== 0) { // null string
3535
// at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
36-
ret = allocateUTF8OnStack(str);
36+
ret = stringToUTF8OnStack(str);
3737
}
3838
return {{{ to64('ret') }}};
3939
},

src/library_dylink.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,13 @@ var LibraryDylink = {
296296
},
297297

298298
$dlSetError__internal: true,
299-
$dlSetError__deps: ['__dl_seterr', '$allocateUTF8OnStack', '$withStackSave'],
299+
$dlSetError__deps: ['__dl_seterr', '$stringToUTF8OnStack', '$withStackSave'],
300300
$dlSetError: function(msg) {
301301
#if DYLINK_DEBUG
302302
dbg('dlSetError: ' + msg);
303303
#endif
304304
withStackSave(function() {
305-
var cmsg = allocateUTF8OnStack(msg);
305+
var cmsg = stringToUTF8OnStack(msg);
306306
___dl_seterr(cmsg, 0);
307307
});
308308
},

src/library_html5.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,7 @@ var LibraryHTML5 = {
24592459
},
24602460
#endif
24612461

2462-
$setCanvasElementSize__deps: ['emscripten_set_canvas_element_size', '$withStackSave', '$allocateUTF8OnStack'],
2462+
$setCanvasElementSize__deps: ['emscripten_set_canvas_element_size', '$withStackSave', '$stringToUTF8OnStack'],
24632463
$setCanvasElementSize: function(target, width, height) {
24642464
#if GL_DEBUG
24652465
dbg('setCanvasElementSize(target='+target+',width='+width+',height='+height);
@@ -2471,7 +2471,7 @@ var LibraryHTML5 = {
24712471
// This function is being called from high-level JavaScript code instead of asm.js/Wasm,
24722472
// and it needs to synchronously proxy over to another thread, so marshal the string onto the heap to do the call.
24732473
withStackSave(function() {
2474-
var targetInt = allocateUTF8OnStack(target.id);
2474+
var targetInt = stringToUTF8OnStack(target.id);
24752475
_emscripten_set_canvas_element_size(targetInt, width, height);
24762476
});
24772477
}
@@ -2533,13 +2533,13 @@ var LibraryHTML5 = {
25332533
#endif
25342534

25352535
// JavaScript-friendly API, returns pair [width, height]
2536-
$getCanvasElementSize__deps: ['emscripten_get_canvas_element_size', '$withStackSave', '$allocateUTF8OnStack'],
2536+
$getCanvasElementSize__deps: ['emscripten_get_canvas_element_size', '$withStackSave', '$stringToUTF8OnStack'],
25372537
$getCanvasElementSize: function(target) {
25382538
return withStackSave(function() {
25392539
var w = stackAlloc(8);
25402540
var h = w + 4;
25412541

2542-
var targetInt = allocateUTF8OnStack(target.id);
2542+
var targetInt = stringToUTF8OnStack(target.id);
25432543
var ret = _emscripten_get_canvas_element_size(targetInt, w, h);
25442544
var size = [{{{ makeGetValue('w', 0, 'i32')}}}, {{{ makeGetValue('h', 0, 'i32')}}}];
25452545
return size;

src/library_legacy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ mergeInto(LibraryManager.library, {
3939
},
4040

4141
$allocateUTF8: '$stringToNewUTF8',
42+
$allocateUTF8OnStack: '$stringToUTF8OnStack',
4243
});

src/library_sockfs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,13 +727,13 @@ mergeInto(LibraryManager.library, {
727727
* Passing a NULL callback function to a emscripten_set_socket_*_callback call
728728
* will deregister the callback registered for that Event.
729729
*/
730-
$_setNetworkCallback__deps: ['$withStackSave', '$allocateUTF8OnStack'],
730+
$_setNetworkCallback__deps: ['$withStackSave', '$stringToUTF8OnStack'],
731731
$_setNetworkCallback: function(event, userData, callback) {
732732
function _callback(data) {
733733
try {
734734
if (event === 'error') {
735735
withStackSave(function() {
736-
var msg = allocateUTF8OnStack(data[2]);
736+
var msg = stringToUTF8OnStack(data[2]);
737737
{{{ makeDynCall('viiii', 'callback') }}}(data[0], data[1], msg, userData);
738738
});
739739
} else {

src/library_stack_trace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
var LibraryStackTrace = {
88
#if DEMANGLE_SUPPORT
9-
$demangle__deps: ['$withStackSave', '__cxa_demangle', 'free', '$allocateUTF8OnStack'],
9+
$demangle__deps: ['$withStackSave', '__cxa_demangle', 'free', '$stringToUTF8OnStack'],
1010
#endif
1111
$demangle: function(func) {
1212
#if DEMANGLE_SUPPORT
@@ -19,7 +19,7 @@ var LibraryStackTrace = {
1919
var s = func;
2020
if (s.startsWith('__Z'))
2121
s = s.substr(1);
22-
var buf = allocateUTF8OnStack(s);
22+
var buf = stringToUTF8OnStack(s);
2323
var status = stackAlloc(4);
2424
var ret = ___cxa_demangle(buf, 0, 0, status);
2525
if ({{{ makeGetValue('status', '0', 'i32') }}} === 0 && ret) {

src/library_strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ mergeInto(LibraryManager.library, {
234234
},
235235

236236
// Allocate stack space for a JS string, and write it there.
237-
$allocateUTF8OnStack: function(str) {
237+
$stringToUTF8OnStack: function(str) {
238238
var size = lengthBytesUTF8(str) + 1;
239239
var ret = stackAlloc(size);
240240
stringToUTF8Array(str, HEAP8, ret, size);

0 commit comments

Comments
 (0)