forked from KolibriOS/kolibrios
linking native Kolibri executable
git-svn-id: svn://kolibrios.org@704 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
//#include "dll.h" // needs to be first
|
||||
#include "variety.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@@ -45,9 +44,7 @@
|
||||
// #include "tinyio.h"
|
||||
#endif
|
||||
#if defined(__WINDOWS_286__) || defined(__NT__)
|
||||
void* _stdcall UserAlloc(int size);
|
||||
|
||||
// #include "windows.h"
|
||||
#include "kolibri.h"
|
||||
#endif
|
||||
#if defined(__OS2__)
|
||||
// #include <wos2.h>
|
||||
@@ -404,7 +401,7 @@ static int __CreateNewNHeap( unsigned amount )
|
||||
#elif defined(__NT__)
|
||||
// brk_value = (unsigned) VirtualAlloc( NULL, amount, MEM_COMMIT,
|
||||
// PAGE_EXECUTE_READWRITE );
|
||||
brk_value = (unsigned) UserAlloc (amount );
|
||||
brk_value = (unsigned) user_alloc(amount );
|
||||
|
||||
//brk_value = (unsigned) LocalAlloc( LMEM_FIXED, amount );
|
||||
if( brk_value == 0 ) {
|
||||
|
@@ -29,7 +29,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
//#include "dll.h" // needs to be first
|
||||
#include "variety.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@@ -40,8 +39,7 @@
|
||||
// #include "extender.h"
|
||||
#endif
|
||||
#if defined(__WINDOWS_286__) || defined(__NT__)
|
||||
int _stdcall UserFree(void* p);
|
||||
// #include "windows.h"
|
||||
#include "kolibri.h"
|
||||
#endif
|
||||
#if defined(__OS2__)
|
||||
// #include <wos2.h>
|
||||
@@ -77,41 +75,6 @@ _WCRTLINK int _nheapmin( void )
|
||||
defined(__WINDOWS_386__) || \
|
||||
defined(__NT__) || \
|
||||
defined(__CALL21__)
|
||||
static int __ReturnMemToSystem( mheapptr mhp )
|
||||
{
|
||||
mheapptr pnext;
|
||||
|
||||
pnext = mhp->next;
|
||||
#if defined(__WARP__)
|
||||
if( DosFreeMem( (PBYTE)mhp ) ) return( -1 );
|
||||
#elif defined(__NT__)
|
||||
//if( LocalFree( (HLOCAL)mhp ) != NULL ) return( -1 );
|
||||
// if (!VirtualFree(mhp, 0, MEM_RELEASE))
|
||||
// return -1;
|
||||
if(!UserFree(mhp))
|
||||
return -1;
|
||||
|
||||
#elif defined(__WINDOWS_386__)
|
||||
if( DPMIFree( (unsigned long)mhp ) != 0 ) return( -1 );
|
||||
#elif defined(__WINDOWS_286__)
|
||||
if( LocalFree( (HLOCAL)mhp ) != NULL ) return( -1 );
|
||||
#elif defined(__CALL21__)
|
||||
// No way to free storage under OSI
|
||||
if( mhp ) return( -1 );
|
||||
#endif
|
||||
if( __MiniHeapRover == mhp ) { // Update rovers
|
||||
if( pnext ) {
|
||||
__MiniHeapRover = pnext;
|
||||
} else {
|
||||
__MiniHeapRover = __nheapbeg;
|
||||
__LargestSizeB4MiniHeapRover = 0;
|
||||
}
|
||||
}
|
||||
if( __MiniHeapFreeRover == mhp ) {
|
||||
__MiniHeapFreeRover = 0;
|
||||
}
|
||||
return( 0 ); // success
|
||||
}
|
||||
|
||||
static void __ReleaseMiniHeap( mheapptr mhp )
|
||||
{
|
||||
@@ -120,7 +83,7 @@ static void __ReleaseMiniHeap( mheapptr mhp )
|
||||
|
||||
pprev = mhp->prev;
|
||||
pnext = mhp->next;
|
||||
if( __ReturnMemToSystem( mhp ) == 0 ) {
|
||||
if( user_free( mhp ) == 1 ) {
|
||||
if( pprev == NULL ) {
|
||||
__nheapbeg = pnext;
|
||||
} else {
|
||||
|
@@ -35,10 +35,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <dos.h>
|
||||
//#include <windows.h>
|
||||
|
||||
void* _stdcall UserAlloc(int size);
|
||||
#include "kolibri.h"
|
||||
|
||||
void* user_alloc(unsigned size);
|
||||
|
||||
extern unsigned _curbrk;
|
||||
extern unsigned _STACKTOP;
|
||||
@@ -52,7 +51,7 @@ _WCRTLINK void _WCNEAR *sbrk( int increment )
|
||||
increment = ( increment + 0x0fff ) & ~0x0fff;
|
||||
//p = LocalAlloc( LMEM_FIXED, increment );
|
||||
//p = VirtualAlloc(NULL, increment, MEM_COMMIT,PAGE_EXECUTE_READWRITE);
|
||||
p = UserAlloc(increment);
|
||||
p = user_alloc(increment);
|
||||
if( p != NULL ) return( p );
|
||||
errno = ENOMEM;
|
||||
}
|
||||
|
Reference in New Issue
Block a user