示例#1
0
BOOL DoLocalInit(WORD wHeapDS, WORD wBytes)
{
     BOOL fResult ;
_asm {
     push DS
     mov  AX, wHeapDS
     mov  DS, AX
     }

        fResult = LocalInit(wHeapDS, 0, wBytes-1);

_asm {
     pop DS
     }
     return fResult ;
}
示例#2
0
	void Module::ThreadLocalInit() {
		pimpl->Instance.reset(this);
		pimpl->ModuleTime.restart();

		Engine::out(Engine::INFO) << "[" << Module::Get()->GetName() << "] New module." << std::endl;

		LocalInit();
		pimpl->ModulesBarrier->wait();
		Init();
		Execute();
		DeInit();

		if (pimpl->useEventQueue) Core::EvtCore->RemoveModule(pimpl->QueueID);
		Engine::out(Engine::INFO) << "[" << Module::Get()->GetName() << "] Thread/Module has exited" << std::endl;
		// without this the thread_specific_ptr would call delete on this module
		pimpl->Instance.release();
	}
示例#3
0
文件: Mgetcrea.c 项目: azulae/Gestool
CLIPPER MGETCREATE( PARAMS ) // ( cClassName, cTitle, nStyle, nLeft, nTop,
                             //   nWidth, nHeight, hWndOwner, hMenu,
                             //   cExtraData, nExStyle ) --> hWnd
{

   DWORD dwStyle   = ( DWORD ) _parnl( 3 );
   DWORD dwExStyle = ( DWORD ) _parnl( 11 );

   #ifndef __FLAT__
   if( ! ghEditDS )
   {
      if( ghEditDS = GlobalAlloc( GMEM_DDESHARE | GMEM_MOVEABLE | GMEM_ZEROINIT, SEGMENT ) )
      {
         lpPtr = GlobalLock( ghEditDS );
         LocalInit( HIWORD( (LONG) lpPtr ), 0,
                    ( WORD )( GlobalSize( ghEditDS ) - 16 ) );
         UnlockSegment( HIWORD( ( LONG ) lpPtr ) );
      }
   }
   _stornl( ( LONG ) ( IF( ghEditDS, ghEditDS, 0 ) ), 10 );    // lpPtr
   #endif

   _retnl( ( LONG ) CreateWindowEx( dwExStyle,
                         _parc( 1 ),      // Class
                         _parc( 2 ),      // Title
                         dwStyle,         // Style
                         _parni( 4 ),     // Left
                         _parni( 5 ),     // Top
                         _parni( 6 ),     // Width
                         _parni( 7 ),     // Height
                         ( HWND ) _parnl( 8 ),     // Parent
                         ( HMENU ) _parnl( 9 ),     // Menu
                         ( HINSTANCE ) IF( ghEditDS,
                         HIWORD( ( LONG ) lpPtr ), __hInstance ),
   ( LPVOID ) ( ( PCOUNT() > 9) ? _parc( 10 ): 0 ) ) ); // Address Window-Creation-Data
}
void * CDECL malloc(size_t size)
{
    SEGHEADER *Seg;         /* segment header pointer */
    WORD    wSeg;           /* segment's selector, must be a stack variable */
    BOOL    NewSeg = FALSE; /* TRUE: a new segment has been allocated */
    void    *Block;         /* obtained block's address */

#if MEMTRACE
    mtr[mtrx].m_func = MTR_MALLOC;
    mtr[mtrx].m_ptr.m_block = NULL;
    mtr[mtrx].m_size = size;
    mtr[mtrx++].m_optimseg = OptimumSeg;
#endif

    if (size == 0) return NULL;

    if (FarStorage == FALSE) {  /* use the local heap */
	HANDLE hMem;

	if ((hMem = LocalAlloc (LMEM_FIXED, size)) != NULL) {
	    return (LPSTR)LocalLock (hMem);
	}
	else return NULL;
    }

    /*-Attempt to suballocate from last used segment */
    if (OptimumSeg) {
	wSeg = HIWORD(OptimumSeg);
#if MEMTRACE
        mtr[mtrx].m_cnt = OptimumSeg->alloc_count;
#endif
	Block = SubAlloc (wSeg, size);
	if (Block != NULL) {
            ++(OptimumSeg->alloc_count);
	    return (char*)Block;     /* quick success ! */
	}
    }

    /*-Scan segment list, attempting to find one where suballocation is
       possible */
    Seg = &SegList;
    for (;;) {
	if (Seg->next == NULL) {
	    /*-initialize a new Segment and chain it on tail */
	    HANDLE      hSeg;
	    DWORD       SegSize;

	    SegSize = max (MINSEGSIZE, HEAPOVH + SEGHEADOFFSET +
				       sizeof(SEGHEADER) + (DWORD)size);
	    hSeg = GlobalAlloc (GMEM_MOVEABLE, SegSize);
	    if (hSeg == NULL) return (char*)NULL;  /* segment allocation
						      failure */
	    SegSize = GlobalSize (hSeg);
	    wSeg = HIWORD(GlobalLock (hSeg));
	    LocalInit (wSeg, 0, SegSize - HEAPOFFSET);
	    GlobalUnlock (hSeg);
	    /* the segment remains locked once, due to LocalInit */

	    SWITCH_DS(wSeg)
	    LockData (0);   /* this ensures the segment's selector will
			       never change */
	    /* note that allocating a GMEM_FIXED segment would have been
	       cleaner but, in Windows 3.0, such segments also end up
	       being page-locked */
	    RESTORE_DS

	    Seg->next = (SEGHEADER*)MAKELONG(SEGHEADOFFSET,wSeg);
	    Seg = Seg->next;
	    Seg->next = NULL;
	    Seg->alloc_count = 0;
	    NewSeg = TRUE;
#if MEMTRACE
    mtr[mtrx].m_func = MTR_MALLOCSEG;
    mtr[mtrx].m_ptr.m_segh = Seg;
    mtr[mtrx].m_cnt = Seg->alloc_count;
    mtr[mtrx].m_size = SegSize;
    mtr[mtrx++].m_optimseg = OptimumSeg;
#endif
	}
	else {
	    Seg = Seg->next;
	    wSeg = HIWORD(Seg);
	}
        
	if (Seg == OptimumSeg) continue;    /* skip this already tried
					       one */
	/*-try to allocate space in that segment */
#if MEMTRACE
        mtr[mtrx].m_cnt = Seg->alloc_count;
#endif
	Block = SubAlloc (wSeg, size);
	if (Block != NULL) ++(Seg->alloc_count);
	if ((Block != NULL) || NewSeg) {
	    OptimumSeg = Seg;   /* next malloc will try this segment
				   first */
	    return (char*)Block;
	}
    }
} /* malloc */
示例#5
0
bool C4ObjectMenu::InitRefSym(const C4TargetFacet &fctSymbol, const char *szEmpty, C4Object *pObject, int32_t iExtra, int32_t iExtraData, int32_t iId, int32_t iStyle, bool fUserMenu)
{
	if (!DoInitRefSym(fctSymbol, szEmpty, iExtra, iExtraData, iId, iStyle)) return false;
	LocalInit(pObject, fUserMenu);
	return true;
}