mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-18 11:00:33 +00:00
filesystem: update optional funcs interface, add platform-specific GetNativeObject call
This commit is contained in:
parent
a40a325d3c
commit
02ce80981c
@ -18,6 +18,7 @@ GNU General Public License for more details.
|
||||
|
||||
#include "common.h"
|
||||
#include "library.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
fs_api_t g_fsapi;
|
||||
fs_globals_t *FI;
|
||||
@ -51,6 +52,8 @@ static fs_interface_t fs_memfuncs =
|
||||
_Mem_Alloc,
|
||||
_Mem_Realloc,
|
||||
_Mem_Free,
|
||||
|
||||
Platform_GetNativeObject,
|
||||
};
|
||||
|
||||
static void FS_UnloadProgs( void )
|
||||
|
@ -1277,33 +1277,34 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
|
||||
return true;
|
||||
}
|
||||
|
||||
poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline )
|
||||
static poolhandle_t _Mem_AllocPool( const char *name, const char *filename, int fileline )
|
||||
{
|
||||
return (poolhandle_t)0xDEADC0DE;
|
||||
}
|
||||
|
||||
void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline )
|
||||
static void _Mem_FreePool( poolhandle_t *poolptr, const char *filename, int fileline )
|
||||
{
|
||||
// stub
|
||||
}
|
||||
|
||||
void* _Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
static void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
{
|
||||
if( clear ) return calloc( 1, size );
|
||||
return malloc( size );
|
||||
void *ptr = malloc( size );
|
||||
if( clear ) memset( ptr, 0, size );
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* _Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
static void *_Mem_Realloc( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline )
|
||||
{
|
||||
return realloc( memptr, size );
|
||||
}
|
||||
|
||||
void _Mem_Free( void *data, const char *filename, int fileline )
|
||||
static void _Mem_Free( void *data, const char *filename, int fileline )
|
||||
{
|
||||
free( data );
|
||||
}
|
||||
|
||||
void _Con_Printf( const char *fmt, ... )
|
||||
static void _Con_Printf( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -1312,7 +1313,7 @@ void _Con_Printf( const char *fmt, ... )
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
void _Sys_Error( const char *fmt, ... )
|
||||
static void _Sys_Error( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -1323,6 +1324,10 @@ void _Sys_Error( const char *fmt, ... )
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
static void *_Platform_GetNativeObject_stub( const char *object )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
@ -2738,7 +2743,8 @@ fs_interface_t g_engfuncs =
|
||||
_Mem_FreePool,
|
||||
_Mem_Alloc,
|
||||
_Mem_Realloc,
|
||||
_Mem_Free
|
||||
_Mem_Free,
|
||||
_Platform_GetNativeObject_stub
|
||||
};
|
||||
|
||||
static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
|
||||
@ -2780,6 +2786,12 @@ static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
|
||||
Con_Reportf( "filesystem_stdio: custom memory allocation functions found\n" );
|
||||
}
|
||||
|
||||
if( engfuncs->_Platform_GetNativeObject )
|
||||
{
|
||||
g_engfuncs._Platform_GetNativeObject = engfuncs->_Platform_GetNativeObject;
|
||||
Con_Reportf( "filesystem_stdio: custom platform-specific functions found\n" );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -204,6 +204,9 @@ typedef struct fs_interface_t
|
||||
void *(*_Mem_Alloc)( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||
void *(*_Mem_Realloc)( poolhandle_t poolptr, void *memptr, size_t size, qboolean clear, const char *filename, int fileline );
|
||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||
|
||||
// platform
|
||||
void *(*_Platform_GetNativeObject)( const char *object );
|
||||
} fs_interface_t;
|
||||
|
||||
typedef int (*FSAPI)( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *interface );
|
||||
|
@ -116,6 +116,7 @@ extern fs_api_t g_api;
|
||||
#define Con_DPrintf (*g_engfuncs._Con_DPrintf)
|
||||
#define Con_Reportf (*g_engfuncs._Con_Reportf)
|
||||
#define Sys_Error (*g_engfuncs._Sys_Error)
|
||||
#define Platform_GetNativeObject (*g_engfuncs.Platform_GetNativeObject)
|
||||
|
||||
//
|
||||
// filesystem.c
|
||||
|
Loading…
x
Reference in New Issue
Block a user