@@ -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 */' ,
@@ -1854,12 +1848,11 @@ mergeInto(LibraryManager.library, {
18541848 return getHostByName ( UTF8ToString ( name ) ) ;
18551849 } ,
18561850
1857- $getHostByName__deps : [ 'malloc' , '$DNS' , '$inetPton4' ] ,
1851+ $getHostByName__deps : [ 'malloc' , '$allocateUTF8' , '$ DNS', '$inetPton4' ] ,
18581852 $getHostByName : function ( name ) {
18591853 // generate hostent
18601854 var ret = _malloc ( { { { C_STRUCTS . hostent . __size__ } } } ) ; // XXX possibly leaked, as are others here
1861- var nameBuf = { { { makeMalloc ( 'getHostByName' , 'name.length+1' ) } } } ;
1862- stringToUTF8 ( name , nameBuf , name . length + 1 ) ;
1855+ var nameBuf = allocateUTF8 ( name ) ;
18631856 { { { makeSetValue ( 'ret' , C_STRUCTS . hostent . h_name , 'nameBuf' , POINTER_TYPE ) } } } ;
18641857 var aliasesBuf = _malloc ( 4 ) ;
18651858 { { { makeSetValue ( 'aliasesBuf' , '0' , '0' , POINTER_TYPE ) } } } ;
@@ -2662,6 +2655,9 @@ mergeInto(LibraryManager.library, {
26622655 // using builtin_malloc to avoid LSan reporting these as leaks.
26632656 emscripten_get_compiler_setting__noleakcheck : true ,
26642657 emscripten_get_compiler_setting__sig : 'pp' ,
2658+ #if RETAIN_COMPILER_SETTINGS
2659+ emscripten_get_compiler_setting__deps : [ '$allocateUTF8' ] ,
2660+ #endif
26652661 emscripten_get_compiler_setting : function ( name ) {
26662662#if RETAIN_COMPILER_SETTINGS
26672663 name = UTF8ToString ( name ) ;
@@ -2673,9 +2669,7 @@ mergeInto(LibraryManager.library, {
26732669 var cache = _emscripten_get_compiler_setting . cache ;
26742670 var fullret = cache [ name ] ;
26752671 if ( fullret ) return fullret ;
2676- cache [ name ] = _malloc ( ret . length + 1 ) ;
2677- stringToUTF8 ( ret + '' , cache [ name ] , ret . length + 1 ) ;
2678- return cache [ name ] ;
2672+ return cache [ name ] = allocateUTF8 ( ret ) ;
26792673#else
26802674 throw 'You must build with -sRETAIN_COMPILER_SETTINGS for getCompilerSetting or emscripten_get_compiler_setting to work' ;
26812675#endif
0 commit comments