@@ -52,13 +52,7 @@ mergeInto(LibraryManager.library, {
5252 // JavaScript <-> C string interop
5353 // ==========================================================================
5454
55- $stringToNewUTF8__deps : [ 'malloc' ] ,
56- $stringToNewUTF8 : function ( jsString ) {
57- var length = lengthBytesUTF8 ( jsString ) + 1 ;
58- var cString = _malloc ( length ) ;
59- stringToUTF8 ( jsString , cString , length ) ;
60- return cString ;
61- } ,
55+ $stringToNewUTF8 : '$allocateUTF8' ,
6256
6357#if ! MINIMAL_RUNTIME
6458 $exitJS__docs : '/** @param {boolean|number=} implicit */' ,
@@ -1833,12 +1827,11 @@ mergeInto(LibraryManager.library, {
18331827 return getHostByName ( UTF8ToString ( name ) ) ;
18341828 } ,
18351829
1836- $getHostByName__deps : [ 'malloc' , '$DNS' , '$inetPton4' ] ,
1830+ $getHostByName__deps : [ 'malloc' , '$allocateUTF8' , '$ DNS', '$inetPton4' ] ,
18371831 $getHostByName : function ( name ) {
18381832 // generate hostent
18391833 var ret = _malloc ( { { { C_STRUCTS . hostent . __size__ } } } ) ; // XXX possibly leaked, as are others here
1840- var nameBuf = { { { makeMalloc ( 'getHostByName' , 'name.length+1' ) } } } ;
1841- stringToUTF8 ( name , nameBuf , name . length + 1 ) ;
1834+ var nameBuf = allocateUTF8 ( name ) ;
18421835 { { { makeSetValue ( 'ret' , C_STRUCTS . hostent . h_name , 'nameBuf' , POINTER_TYPE ) } } } ;
18431836 var aliasesBuf = _malloc ( 4 ) ;
18441837 { { { makeSetValue ( 'aliasesBuf' , '0' , '0' , POINTER_TYPE ) } } } ;
@@ -2628,6 +2621,9 @@ mergeInto(LibraryManager.library, {
26282621 // We never free the return values of this function so we need to allocate
26292622 // using builtin_malloc to avoid LSan reporting these as leaks.
26302623 emscripten_get_compiler_setting__noleakcheck : true ,
2624+ #if RETAIN_COMPILER_SETTINGS
2625+ emscripten_get_compiler_setting__deps : [ '$allocateUTF8' ] ,
2626+ #endif
26312627 emscripten_get_compiler_setting : function ( name ) {
26322628#if RETAIN_COMPILER_SETTINGS
26332629 name = UTF8ToString ( name ) ;
@@ -2639,9 +2635,7 @@ mergeInto(LibraryManager.library, {
26392635 var cache = _emscripten_get_compiler_setting . cache ;
26402636 var fullret = cache [ name ] ;
26412637 if ( fullret ) return fullret ;
2642- cache [ name ] = _malloc ( ret . length + 1 ) ;
2643- stringToUTF8 ( ret + '' , cache [ name ] , ret . length + 1 ) ;
2644- return cache [ name ] ;
2638+ return cache [ name ] = allocateUTF8 ( ret ) ;
26452639#else
26462640 throw 'You must build with -sRETAIN_COMPILER_SETTINGS for getCompilerSetting or emscripten_get_compiler_setting to work' ;
26472641#endif
0 commit comments