@@ -736,20 +736,19 @@ void getpath(HINSTANCE hi, C* path)
736
736
// create a skeletal JS--just good enough to do basic initialisation
737
737
JS heapinit ()
738
738
{
739
- JS jt = jmreserve (sizeof (JST ),__builtin_ctz (JTALIGNBDY ));
740
- if (!jt )R 0 ; //no address space
741
- I sz = (I )& jt -> threaddata [2 ]- (I )jt ; // #relevant bytes: just JS and the first JT
742
- if (!jmcommit (jt ,sz )){jmrelease (jt ,sizeof (JST ));R 0 ;} //no memory
743
- mvc (sz ,jt ,1 ,MEMSET00 );
744
- R jt ;
739
+ JS jt = jmreservea (sizeof (JST ),__builtin_ctz (JTALIGNBDY ));
740
+ if (!jt )R 0 ; //no address space
741
+ I sz = (I )& jt -> threaddata [1 ]- (I )jt ; // #relevant bytes: just JS and the first JT
742
+ if (!jmcommit (jt ,sz )){jmrelease (jt ,sizeof (JST ));R 0 ;} //no memory
743
+ R jt ;
745
744
}
746
745
747
746
int WINAPI DllMain (HINSTANCE hDLL , DWORD dwReason , LPVOID lpReserved )
748
747
{
749
748
switch (dwReason )
750
749
{
751
- case DLL_PROCESS_ATTACH :
752
- // Handle the first activation of J
750
+ case DLL_PROCESS_ATTACH :
751
+ // Handle the first activation of J
753
752
g_hinst = hDLL ;
754
753
/*
755
754
{
@@ -768,11 +767,9 @@ int WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
768
767
// just enough to do GA(). The rest of jt is never used
769
768
getpath (0 , modulepath );
770
769
getpath (hDLL , dllpath );
771
- g_jt = heapinit ()
770
+ g_jt = heapinit ();
772
771
if (!g_jt ) R 0 ; // abort if no memory
773
772
if (!jtglobinit (g_jt )) {jmrelease (g_jt ,sizeof (JST )); g_jt = 0 ; R 0 ;}; // free & abort if initialization error
774
- // The g_jt heap MUST NOT be freed, because it holds the blocks pointed to by initialized globals.
775
- // g_jt itself, a JST struct, is not used. Perhaps it could be freed, as long as the rest of the heap remains.
776
773
break ;
777
774
778
775
case DLL_THREAD_ATTACH :
@@ -792,14 +789,14 @@ CDPROC JS _stdcall JInit()
792
789
{
793
790
JST * jt ;
794
791
795
- // Init for a new J instance. Globals have already been initialized.
796
- // Create a new jt, which will be the one we use for the entirety of the instance.
797
- jt = heapinit (1000000 );
792
+ // Init for a new J instance. Globals have already been initialized.
793
+ // Create a new jt, which will be the one we use for the entirety of the instance.
794
+ jt = heapinit ();
798
795
if (!jt ) R 0 ; // if no memory, fail
799
- // Initialize all the info for the shared region and the master thread
796
+ // Initialize all the info for the shared region and the master thread
800
797
if (!jtjinit2 (jt ,0 ,0 ))
801
798
{
802
- HeapDestroy ( JT ( jt ,heap )); // if error during init, fail
799
+ jmrelease ( jt ,sizeof ( JST )); // if error during init, fail
803
800
R 0 ;
804
801
};
805
802
return jt ; // return (JS)MTHREAD(jt);
@@ -809,11 +806,11 @@ CDPROC JS _stdcall JInit()
809
806
CDPROC int _stdcall JFree (JS jt )
810
807
{
811
808
if (!jt ) return 0 ;
812
- SETJTJM (jt ,jt ,jm )
809
+ SETJTJM (jt ,jt ,jm )
813
810
#if !SY_WINCE
814
811
dllquit (jm ); // clean up call dll
815
812
#endif
816
- HeapDestroy ( JT ( jt ,heap ));
813
+ jmrelease ( jt ,sizeof ( JST ));
817
814
return 0 ;
818
815
}
819
816
0 commit comments