void Thread::Dispose() { int tid = this->threadId, sid=this->spaceId; if( this->disposed ) return; this->disposed = true; if( tid > 0 ) SysTerminateThread( sid, tid ); if( ti && ti->StackBase ) SysFreeMemory( sid, (void*)ti->StackBase ); if( ti->Self ) SysFreeMemory( sid, (void*)ti->Self ); if( ti ) SysFreeMemory( SysGetCurrentSpaceId(), this->ti ); tid = 0; if( this->prev ) this->prev->next = this->next; else process->mainThread = this->next; if( this->next ) this->next->prev = this->prev; }
void Process::Dispose() { if( this->disposed ) return; this->disposed = true; for( Thread* t = this->mainThread; t; ){ Thread* d = t; t = t->NextThread(); delete d; } if( this->module ){ FreeModule( this->module, this->spaceId ); } if( this->spaceId ){ SysDestroySpace( this->spaceId, this->exitCode ); this->spaceId = 0; } if( this->pi ){ SysFreeMemory( SysGetCurrentSpaceId(), this->pi ); } //release resources if( this->commandLine ) SysFreeMemory( SysGetCurrentSpaceId(), this->commandLine ); if( this->environment ) SysFreeMemory( SysGetCurrentSpaceId(), this->environment ); this->commandLine = 0; this->environment = 0; //remove from tree if( this==firstProcess ){ firstProcess = this->next; }else if( this->parent || this->prev ){ if( this->prev ) this->prev->next = this->next; if( this->next ) this->next->prev = this->prev; } KillProcessChildren( this ); }
static void delete_buffer( const void* ptr ) { buffer_t* buf = (buffer_t*)ptr; SysFreeMemory(SysGetCurrentSpaceId(), buf->data); free(buf); }
static zSHORT GetAnzahlCatalogFiles( zVIEW vSubtask, zVIEW vAktView) { zSHORT nRet; zLONG lHMem; zLONG lAnzCatalogFiles; zLONG lLv; zCHAR *pszCatalogFileList = NULL; void *pEnv = NULL; // First we have to get the number of catalogfiles from the environment file // SIRENV if (g_hLib == NULL) { nRet = fnLoadHzvaffz (vSubtask); if ( nRet != 0 ) return( nRet ); } // Open the environment nRet = pfnOpenEnv (&pEnv); if ( nRet != 0 ) return( nRet ); nRet = pfnGetAnzahlCatalogFiles (pEnv, &lAnzCatalogFiles); if ( nRet != 0 ) { pfnFreeEnv( pEnv ); return( nRet ); } // Get Memory for the whole cataloglist // max. length of a catalogname shoud be 9 characters lHMem = SysAllocMemory( &pszCatalogFileList, lAnzCatalogFiles * 9, 0, zCOREMEM_ALLOC, 0 ); if ( lHMem == 0 ) { pfnFreeEnv( pEnv ); return( 552); } memset(pszCatalogFileList, 0, lAnzCatalogFiles * 9); // Get all Catalogfilenames from the Environmentfile nRet = pfnGetAllCatalogFiles (pEnv, pszCatalogFileList, lAnzCatalogFiles); pfnFreeEnv( pEnv ); if ( nRet != 0 ) { SysFreeMemory (lHMem); return( nRet ); } // Set all Catalogfilenames into the WorkLOD for ( lLv = 0; lLv < lAnzCatalogFiles; lLv++ ) { CreateEntity( vAktView, "CatFiles", zPOS_AFTER ); SetAttributeFromString(vAktView, "CatFiles", "wkCatFiles", pszCatalogFileList); SetAttributeFromString( vAktView, "CatFiles", "wkEinschraenkung", ""); pszCatalogFileList += 9; } // Free all Memory SysFreeMemory( lHMem ); return( 0 ); }
//////////////////////////////////////////////////////////////////////////////////////////////////////// // // OPERATION: GetAllServerNames // zOPER_EXPORT zSHORT OPERATION GetAllServerNames( zVIEW vSubtask, zVIEW vAktView ) { zSHORT nRet; void *pEnv = NULL; zCHAR *pszServerList = NULL; long lAnzServer; long lHMem; long lLv; unsigned long lLocalLength; zCHAR szLocalServer[MAX_COMPUTERNAME_LENGTH+1]; // If the serverlist still exists, return nRet = CheckExistenceOfEntity( vAktView, "TZSIIMWK"); if ( nRet == zCURSOR_SET || nRet == zCALL_ERROR ) return( nRet ); // Load hzvaffz.dll and get the function pointers if ( g_hLib != NULL ) { nRet = fnLoadHzvaffz (vSubtask); if (nRet != 0 ) return( nRet ); } nRet = pfnOpenEnv( &pEnv ); if ( nRet != 0 ) return( nRet ); nRet = pfnGetAnzahlServerNames (pEnv, &lAnzServer); if ( nRet != 0 ) { pfnFreeEnv (pEnv); return( nRet ); } lAnzServer += 1; // The local servername is not in the list // Get Memory for the whole serverlist // max. length of a servername shoud be 9 characters lHMem = SysAllocMemory( &pszServerList, lAnzServer * 9, 0, zCOREMEM_ALLOC, 0 ); if ( lHMem == 0 ) { pfnFreeEnv( pEnv ); return( 551 ); } // Now get the Local Server Name lLocalLength = MAX_COMPUTERNAME_LENGTH + 1; memset(szLocalServer, 0, MAX_COMPUTERNAME_LENGTH + 1); if (GetComputerName( szLocalServer, &lLocalLength ) == 0 ) { pfnFreeEnv( pEnv ); return( -3 ); } // Put the local Server name into the list memset( pszServerList, 0, lAnzServer * 9 ); memcpy( pszServerList, szLocalServer, 9 ); // Get all Servernames nRet = pfnGetAllServerNames( pEnv, pszServerList+9, lAnzServer - 1 ); pfnFreeEnv( pEnv ); if ( nRet != 0 ) { SysFreeMemory( lHMem ); return( nRet ); } // Set all Servernames into the WorkLOD for ( lLv = 0; lLv < lAnzServer; lLv++ ) { CreateEntity( vAktView, "TZSIIMWK", zPOS_AFTER ); SetAttributeFromString( vAktView, "TZSIIMWK", "wkServerName", pszServerList ); pszServerList += 9; } SysFreeMemory( lHMem ); return( 0 ); }