Skip to content

Commit 5b6e7be

Browse files
committed
windows
1 parent 0dbd782 commit 5b6e7be

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

dllsrc/jdll.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -736,20 +736,19 @@ void getpath(HINSTANCE hi, C* path)
736736
// create a skeletal JS--just good enough to do basic initialisation
737737
JS heapinit()
738738
{
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;
745744
}
746745

747746
int WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
748747
{
749748
switch (dwReason)
750749
{
751-
case DLL_PROCESS_ATTACH:
752-
// Handle the first activation of J
750+
case DLL_PROCESS_ATTACH:
751+
// Handle the first activation of J
753752
g_hinst = hDLL;
754753
/*
755754
{
@@ -768,11 +767,9 @@ int WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
768767
// just enough to do GA(). The rest of jt is never used
769768
getpath(0, modulepath);
770769
getpath(hDLL, dllpath);
771-
g_jt=heapinit()
770+
g_jt=heapinit();
772771
if(!g_jt) R 0; // abort if no memory
773772
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.
776773
break;
777774

778775
case DLL_THREAD_ATTACH:
@@ -792,14 +789,14 @@ CDPROC JS _stdcall JInit()
792789
{
793790
JST* jt;
794791

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();
798795
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
800797
if(!jtjinit2(jt,0,0))
801798
{
802-
HeapDestroy(JT(jt,heap)); // if error during init, fail
799+
jmrelease(jt,sizeof(JST)); // if error during init, fail
803800
R 0;
804801
};
805802
return jt; // return (JS)MTHREAD(jt);
@@ -809,11 +806,11 @@ CDPROC JS _stdcall JInit()
809806
CDPROC int _stdcall JFree(JS jt)
810807
{
811808
if(!jt) return 0;
812-
SETJTJM(jt,jt,jm)
809+
SETJTJM(jt,jt,jm)
813810
#if !SY_WINCE
814811
dllquit(jm); // clean up call dll
815812
#endif
816-
HeapDestroy(JT(jt,heap));
813+
jmrelease(jt,sizeof(JST));
817814
return 0;
818815
}
819816

jsrc/m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void *jmreservea(I n,I a){
116116
void *jmalloca(I n,I a){
117117
MEM_ADDRESS_REQUIREMENTS req = {.Alignment=1<<a};
118118
MEM_EXTENDED_PARAMETER opt = {.Type=MemExtendedParameterAddressRequirements, .Pointer=&req};
119-
R VirtualAlloc2(0,0,n,MEM_RESERVE|MM_COMMIT,PAGE_READWRITE,&opt,1);}
119+
R VirtualAlloc2(0,0,n,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE,&opt,1);}
120120
#endif
121121

122122
#if LEAKSNIFF

0 commit comments

Comments
 (0)