Take best fitting type for available memory measurement.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31152 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1244,7 +1244,7 @@ current computer and/or user characteristics.
|
|||||||
|
|
||||||
\membersection{::wxGetFreeMemory}\label{wxgetfreememory}
|
\membersection{::wxGetFreeMemory}\label{wxgetfreememory}
|
||||||
|
|
||||||
\func{long}{wxGetFreeMemory}{\void}
|
\func{wxMemorySize}{wxGetFreeMemory}{\void}
|
||||||
|
|
||||||
Returns the amount of free memory in bytes under environments which
|
Returns the amount of free memory in bytes under environments which
|
||||||
support it, and -1 if not supported. Currently, it is supported only
|
support it, and -1 if not supported. Currently, it is supported only
|
||||||
|
@@ -61,6 +61,18 @@ class WXDLLIMPEXP_CORE wxPoint;
|
|||||||
#define wxMax(a,b) (((a) > (b)) ? (a) : (b))
|
#define wxMax(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#define wxMin(a,b) (((a) < (b)) ? (a) : (b))
|
#define wxMin(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
||||||
|
// wxGetFreeMemory can return huge amount of memory on 64-bit platforms
|
||||||
|
// define wxMemorySize according to the type which best fits your platform
|
||||||
|
#if wxUSE_LONGLONG && defined(__WIN64__)
|
||||||
|
// 64 bit Windowses have sizeof(long) only 32 bit long
|
||||||
|
// we need to use wxLongLong to express memory sizes
|
||||||
|
#define wxMemorySize wxLongLong
|
||||||
|
#else
|
||||||
|
// 64 bit UNIX has sizeof(long) = 64
|
||||||
|
// assume 32 bit platforms cannnot return more than 32bits of
|
||||||
|
#define wxMemorySize long
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// String functions (deprecated, use wxString)
|
// String functions (deprecated, use wxString)
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -283,7 +295,7 @@ wxDEPRECATED( WXDLLIMPEXP_BASE void wxUsleep(unsigned long milliseconds) );
|
|||||||
WXDLLIMPEXP_BASE unsigned long wxGetProcessId();
|
WXDLLIMPEXP_BASE unsigned long wxGetProcessId();
|
||||||
|
|
||||||
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
||||||
WXDLLIMPEXP_BASE long wxGetFreeMemory();
|
WXDLLIMPEXP_BASE wxMemorySize wxGetFreeMemory();
|
||||||
|
|
||||||
// should wxApp::OnFatalException() be called?
|
// should wxApp::OnFatalException() be called?
|
||||||
WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = true);
|
WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = true);
|
||||||
|
@@ -260,7 +260,7 @@ bool wxGetHostName(wxChar *buf, int maxSize)
|
|||||||
else
|
else
|
||||||
buf[0] = 0 ;
|
buf[0] = 0 ;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user ID e.g. jacs
|
// Get user ID e.g. jacs
|
||||||
@@ -298,7 +298,7 @@ bool wxGetUserName(wxChar *buf, int maxSize)
|
|||||||
else
|
else
|
||||||
buf[0] = 0 ;
|
buf[0] = 0 ;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags)
|
int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags)
|
||||||
@@ -313,7 +313,7 @@ WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value)
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the env var name to the given value, return TRUE on success
|
// set the env var name to the given value, return true on success
|
||||||
WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
|
WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
|
||||||
{
|
{
|
||||||
// TODO : under classic there is no environement support, under X yes
|
// TODO : under classic there is no environement support, under X yes
|
||||||
@@ -326,20 +326,20 @@ WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
|
|||||||
bool wxShell(const wxString& command)
|
bool wxShell(const wxString& command)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown or reboot the PC
|
// Shutdown or reboot the PC
|
||||||
bool wxShutdown(wxShutdownFlags wFlags)
|
bool wxShutdown(wxShutdownFlags wFlags)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
||||||
long wxGetFreeMemory()
|
wxMemorySize wxGetFreeMemory()
|
||||||
{
|
{
|
||||||
return FreeMem() ;
|
return (wxMemorySize)FreeMem() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
@@ -406,7 +406,7 @@ wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
|||||||
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
|
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
|
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
|
||||||
@@ -436,7 +436,7 @@ bool wxWriteResource(const wxString& section, const wxString& entry, int value,
|
|||||||
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
|
||||||
@@ -447,9 +447,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, float *value,
|
|||||||
{
|
{
|
||||||
*value = (float)strtod(s, NULL);
|
*value = (float)strtod(s, NULL);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
|
||||||
@@ -460,9 +460,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, long *value,
|
|||||||
{
|
{
|
||||||
*value = strtol(s, NULL, 10);
|
*value = strtol(s, NULL, 10);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
|
||||||
@@ -473,9 +473,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c
|
|||||||
{
|
{
|
||||||
*value = (int)strtol(s, NULL, 10);
|
*value = (int)strtol(s, NULL, 10);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return false;
|
||||||
}
|
}
|
||||||
#endif // wxUSE_RESOURCES
|
#endif // wxUSE_RESOURCES
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ void wxEndBusyCursor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRUE if we're between the above two calls
|
// true if we're between the above two calls
|
||||||
bool wxIsBusy()
|
bool wxIsBusy()
|
||||||
{
|
{
|
||||||
return (gs_wxBusyCursorCount > 0);
|
return (gs_wxBusyCursorCount > 0);
|
||||||
@@ -539,7 +539,7 @@ wxString wxMacFindFolder( short vol,
|
|||||||
bool wxCheckForInterrupt(wxWindow *wnd)
|
bool wxCheckForInterrupt(wxWindow *wnd)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGetMousePosition( int* x, int* y )
|
void wxGetMousePosition( int* x, int* y )
|
||||||
@@ -552,10 +552,10 @@ void wxGetMousePosition( int* x, int* y )
|
|||||||
*y = pt.v ;
|
*y = pt.v ;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return TRUE if we have a colour display
|
// Return true if we have a colour display
|
||||||
bool wxColourDisplay()
|
bool wxColourDisplay()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns depth of screen
|
// Returns depth of screen
|
||||||
@@ -644,7 +644,7 @@ wxChar *wxGetUserHome (const wxString& user)
|
|||||||
bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
|
bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
|
||||||
{
|
{
|
||||||
if ( path.empty() )
|
if ( path.empty() )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
wxString p = path ;
|
wxString p = path ;
|
||||||
if (p[0u] == ':' ) {
|
if (p[0u] == ':' ) {
|
||||||
|
@@ -114,7 +114,7 @@ bool wxGetHostName(wxChar *buf, int maxSize)
|
|||||||
else
|
else
|
||||||
buf[0] = 0 ;
|
buf[0] = 0 ;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user ID e.g. jacs
|
// Get user ID e.g. jacs
|
||||||
@@ -152,7 +152,7 @@ bool wxGetUserName(wxChar *buf, int maxSize)
|
|||||||
else
|
else
|
||||||
buf[0] = 0 ;
|
buf[0] = 0 ;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags)
|
int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags)
|
||||||
@@ -167,7 +167,7 @@ WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value)
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the env var name to the given value, return TRUE on success
|
// set the env var name to the given value, return true on success
|
||||||
WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
|
WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
|
||||||
{
|
{
|
||||||
// TODO : under classic there is no environement support, under X yes
|
// TODO : under classic there is no environement support, under X yes
|
||||||
@@ -180,20 +180,20 @@ WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
|
|||||||
bool wxShell(const wxString& command)
|
bool wxShell(const wxString& command)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown or reboot the PC
|
// Shutdown or reboot the PC
|
||||||
bool wxShutdown(wxShutdownFlags wFlags)
|
bool wxShutdown(wxShutdownFlags wFlags)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
||||||
long wxGetFreeMemory()
|
wxMemorySize wxGetFreeMemory()
|
||||||
{
|
{
|
||||||
return FreeMem() ;
|
return (wxMemorySize)FreeMem() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxUsleep(unsigned long milliseconds)
|
void wxUsleep(unsigned long milliseconds)
|
||||||
@@ -253,7 +253,7 @@ wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
|||||||
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
|
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
|
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
|
||||||
@@ -283,7 +283,7 @@ bool wxWriteResource(const wxString& section, const wxString& entry, int value,
|
|||||||
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
|
||||||
@@ -294,9 +294,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, float *value,
|
|||||||
{
|
{
|
||||||
*value = (float)strtod(s, NULL);
|
*value = (float)strtod(s, NULL);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
|
||||||
@@ -307,9 +307,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, long *value,
|
|||||||
{
|
{
|
||||||
*value = strtol(s, NULL, 10);
|
*value = strtol(s, NULL, 10);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
|
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
|
||||||
@@ -320,9 +320,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c
|
|||||||
{
|
{
|
||||||
*value = (int)strtol(s, NULL, 10);
|
*value = (int)strtol(s, NULL, 10);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return false;
|
||||||
}
|
}
|
||||||
#endif // wxUSE_RESOURCES
|
#endif // wxUSE_RESOURCES
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ void wxEndBusyCursor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRUE if we're between the above two calls
|
// true if we're between the above two calls
|
||||||
bool wxIsBusy()
|
bool wxIsBusy()
|
||||||
{
|
{
|
||||||
return (gs_wxBusyCursorCount > 0);
|
return (gs_wxBusyCursorCount > 0);
|
||||||
@@ -392,7 +392,7 @@ wxString wxMacFindFolder( short vol,
|
|||||||
bool wxCheckForInterrupt(wxWindow *wnd)
|
bool wxCheckForInterrupt(wxWindow *wnd)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGetMousePosition( int* x, int* y )
|
void wxGetMousePosition( int* x, int* y )
|
||||||
@@ -405,10 +405,10 @@ void wxGetMousePosition( int* x, int* y )
|
|||||||
*y = pt.v ;
|
*y = pt.v ;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return TRUE if we have a colour display
|
// Return true if we have a colour display
|
||||||
bool wxColourDisplay()
|
bool wxColourDisplay()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns depth of screen
|
// Returns depth of screen
|
||||||
@@ -524,7 +524,7 @@ wxChar *wxGetUserHome (const wxString& user)
|
|||||||
bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
|
bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
|
||||||
{
|
{
|
||||||
if ( path.empty() )
|
if ( path.empty() )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
wxString p = path ;
|
wxString p = path ;
|
||||||
if (p[0u] == ':' ) {
|
if (p[0u] == ':' ) {
|
||||||
|
@@ -1010,15 +1010,20 @@ bool wxShutdown(wxShutdownFlags wFlags)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
||||||
long wxGetFreeMemory()
|
wxMemorySize wxGetFreeMemory()
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__) && !defined(__BORLANDC__)
|
#if defined(__WIN64__)
|
||||||
|
MEMORYSTATUSEX memStatex;
|
||||||
|
statex.dwLength = sizeof (statex);
|
||||||
|
GlobalMemoryStatusEx (&statex);
|
||||||
|
return (wxMemorySize)memStatus.ullAvailPhys;
|
||||||
|
#elif defined(__WIN32__) && !defined(__BORLANDC__)
|
||||||
MEMORYSTATUS memStatus;
|
MEMORYSTATUS memStatus;
|
||||||
memStatus.dwLength = sizeof(MEMORYSTATUS);
|
memStatus.dwLength = sizeof(MEMORYSTATUS);
|
||||||
GlobalMemoryStatus(&memStatus);
|
GlobalMemoryStatus(&memStatus);
|
||||||
return memStatus.dwAvailPhys;
|
return (wxMemorySize)memStatus.dwAvailPhys;
|
||||||
#else
|
#else
|
||||||
return (long)GetFreeSpace(0);
|
return (wxMemorySize)GetFreeSpace(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -95,7 +95,7 @@ bool wxGetHostName(
|
|||||||
wxStrncpy(zBuf, zSysname, nMaxSize - 1);
|
wxStrncpy(zBuf, zSysname, nMaxSize - 1);
|
||||||
zBuf[nMaxSize] = _T('\0');
|
zBuf[nMaxSize] = _T('\0');
|
||||||
#endif
|
#endif
|
||||||
return *zBuf ? TRUE : FALSE;
|
return *zBuf ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user ID e.g. jacs
|
// Get user ID e.g. jacs
|
||||||
@@ -108,9 +108,9 @@ bool wxGetUserId(
|
|||||||
long lrc;
|
long lrc;
|
||||||
// UPM procs return 0 on success
|
// UPM procs return 0 on success
|
||||||
lrc = U32ELOCU((unsigned char*)zBuf, (unsigned long *)&nType);
|
lrc = U32ELOCU((unsigned char*)zBuf, (unsigned long *)&nType);
|
||||||
if (lrc == 0) return TRUE;
|
if (lrc == 0) return true;
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetUserName(
|
bool wxGetUserName(
|
||||||
@@ -125,7 +125,7 @@ bool wxGetUserName(
|
|||||||
#else
|
#else
|
||||||
wxStrncpy(zBuf, _T("Unknown User"), nMaxSize);
|
wxStrncpy(zBuf, _T("Unknown User"), nMaxSize);
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxKill(
|
int wxKill(
|
||||||
@@ -201,11 +201,11 @@ bool wxShell(
|
|||||||
bool wxShutdown(wxShutdownFlags wFlags)
|
bool wxShutdown(wxShutdownFlags wFlags)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
||||||
long wxGetFreeMemory()
|
wxMemorySize wxGetFreeMemory()
|
||||||
{
|
{
|
||||||
void* pMemptr = NULL;
|
void* pMemptr = NULL;
|
||||||
ULONG lSize;
|
ULONG lSize;
|
||||||
@@ -215,8 +215,8 @@ long wxGetFreeMemory()
|
|||||||
lMemFlags = PAG_FREE;
|
lMemFlags = PAG_FREE;
|
||||||
rc = ::DosQueryMem(pMemptr, &lSize, &lMemFlags);
|
rc = ::DosQueryMem(pMemptr, &lSize, &lMemFlags);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return -1L;
|
lSize = -1L;
|
||||||
return (long)lSize;
|
return (wxMemorySize)lSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -228,14 +228,14 @@ bool wxGetEnv(const wxString& var, wxString *value)
|
|||||||
// wxGetenv is defined as getenv()
|
// wxGetenv is defined as getenv()
|
||||||
wxChar *p = wxGetenv(var);
|
wxChar *p = wxGetenv(var);
|
||||||
if ( !p )
|
if ( !p )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if ( value )
|
if ( value )
|
||||||
{
|
{
|
||||||
*value = p;
|
*value = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSetEnv(const wxString& variable, const wxChar *value)
|
bool wxSetEnv(const wxString& variable, const wxChar *value)
|
||||||
@@ -257,7 +257,7 @@ bool wxSetEnv(const wxString& variable, const wxChar *value)
|
|||||||
|
|
||||||
return putenv(buf) == 0;
|
return putenv(buf) == 0;
|
||||||
#else // no way to set an env var
|
#else // no way to set an env var
|
||||||
return FALSE;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -156,7 +156,7 @@ bool wxShutdown(wxShutdownFlags wFlags)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
|
||||||
long wxGetFreeMemory()
|
wxMemorySize wxGetFreeMemory()
|
||||||
{
|
{
|
||||||
uint32_t freeTotal = 0;
|
uint32_t freeTotal = 0;
|
||||||
uint32_t freeHeap;
|
uint32_t freeHeap;
|
||||||
@@ -171,7 +171,7 @@ long wxGetFreeMemory()
|
|||||||
freeTotal+=freeHeap;
|
freeTotal+=freeHeap;
|
||||||
}
|
}
|
||||||
|
|
||||||
return freeTotal;
|
return (wxMemorySize)freeTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxGetProcessId()
|
unsigned long wxGetProcessId()
|
||||||
|
@@ -259,7 +259,7 @@ long wxExecute( const wxString& command, int flags, wxProcess *process )
|
|||||||
wxString argument;
|
wxString argument;
|
||||||
const wxChar *cptr = command.c_str();
|
const wxChar *cptr = command.c_str();
|
||||||
wxChar quotechar = wxT('\0'); // is arg quoted?
|
wxChar quotechar = wxT('\0'); // is arg quoted?
|
||||||
bool escaped = FALSE;
|
bool escaped = false;
|
||||||
|
|
||||||
// split the command line in arguments
|
// split the command line in arguments
|
||||||
do
|
do
|
||||||
@@ -278,14 +278,14 @@ long wxExecute( const wxString& command, int flags, wxProcess *process )
|
|||||||
{
|
{
|
||||||
if ( *cptr == wxT('\\') && ! escaped )
|
if ( *cptr == wxT('\\') && ! escaped )
|
||||||
{
|
{
|
||||||
escaped = TRUE;
|
escaped = true;
|
||||||
cptr++;
|
cptr++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// all other characters:
|
// all other characters:
|
||||||
argument += *cptr++;
|
argument += *cptr++;
|
||||||
escaped = FALSE;
|
escaped = false;
|
||||||
|
|
||||||
// have we reached the end of the argument?
|
// have we reached the end of the argument?
|
||||||
if ( (*cptr == quotechar && ! escaped)
|
if ( (*cptr == quotechar && ! escaped)
|
||||||
@@ -348,7 +348,7 @@ bool wxShell(const wxString& command)
|
|||||||
|
|
||||||
bool wxShell(const wxString& command, wxArrayString& output)
|
bool wxShell(const wxString& command, wxArrayString& output)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( !!command, FALSE, _T("can't exec shell non interactively") );
|
wxCHECK_MSG( !command.empty(), false, _T("can't exec shell non interactively") );
|
||||||
|
|
||||||
return wxExecute(wxMakeShellCommand(command), output);
|
return wxExecute(wxMakeShellCommand(command), output);
|
||||||
}
|
}
|
||||||
@@ -369,7 +369,7 @@ bool wxShutdown(wxShutdownFlags wFlags)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( _T("unknown wxShutdown() flag") );
|
wxFAIL_MSG( _T("unknown wxShutdown() flag") );
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return system(wxString::Format(_T("init %c"), level).mb_str()) == 0;
|
return system(wxString::Format(_T("init %c"), level).mb_str()) == 0;
|
||||||
@@ -385,7 +385,7 @@ bool wxShutdown(wxShutdownFlags wFlags)
|
|||||||
bool wxPipeInputStream::CanRead() const
|
bool wxPipeInputStream::CanRead() const
|
||||||
{
|
{
|
||||||
if ( m_lasterror == wxSTREAM_EOF )
|
if ( m_lasterror == wxSTREAM_EOF )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// check if there is any input available
|
// check if there is any input available
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
@@ -404,7 +404,7 @@ bool wxPipeInputStream::CanRead() const
|
|||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(_T("unexpected select() return value"));
|
wxFAIL_MSG(_T("unexpected select() return value"));
|
||||||
@@ -724,7 +724,7 @@ char *wxGetUserHome( const wxString &user )
|
|||||||
// private use only)
|
// private use only)
|
||||||
static bool wxGetHostNameInternal(wxChar *buf, int sz)
|
static bool wxGetHostNameInternal(wxChar *buf, int sz)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( buf, FALSE, wxT("NULL pointer in wxGetHostNameInternal") );
|
wxCHECK_MSG( buf, false, wxT("NULL pointer in wxGetHostNameInternal") );
|
||||||
|
|
||||||
*buf = wxT('\0');
|
*buf = wxT('\0');
|
||||||
|
|
||||||
@@ -742,7 +742,7 @@ static bool wxGetHostNameInternal(wxChar *buf, int sz)
|
|||||||
#else // no uname, no gethostname
|
#else // no uname, no gethostname
|
||||||
wxFAIL_MSG(wxT("don't know host name for this machine"));
|
wxFAIL_MSG(wxT("don't know host name for this machine"));
|
||||||
|
|
||||||
bool ok = FALSE;
|
bool ok = false;
|
||||||
#endif // uname/gethostname
|
#endif // uname/gethostname
|
||||||
|
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
@@ -785,7 +785,7 @@ bool wxGetFullHostName(wxChar *buf, int sz)
|
|||||||
{
|
{
|
||||||
wxLogSysError(_("Cannot get the official hostname"));
|
wxLogSysError(_("Cannot get the official hostname"));
|
||||||
|
|
||||||
ok = FALSE;
|
ok = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -807,10 +807,10 @@ bool wxGetUserId(wxChar *buf, int sz)
|
|||||||
if ((who = getpwuid(getuid ())) != NULL)
|
if ((who = getpwuid(getuid ())) != NULL)
|
||||||
{
|
{
|
||||||
wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1);
|
wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGetUserName(wxChar *buf, int sz)
|
bool wxGetUserName(wxChar *buf, int sz)
|
||||||
@@ -829,10 +829,10 @@ bool wxGetUserName(wxChar *buf, int sz)
|
|||||||
#else // !HAVE_PW_GECOS
|
#else // !HAVE_PW_GECOS
|
||||||
wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1);
|
wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1);
|
||||||
#endif // HAVE_PW_GECOS/!HAVE_PW_GECOS
|
#endif // HAVE_PW_GECOS/!HAVE_PW_GECOS
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function is in mac/utils.cpp for wxMac
|
// this function is in mac/utils.cpp for wxMac
|
||||||
@@ -863,7 +863,7 @@ unsigned long wxGetProcessId()
|
|||||||
return (unsigned long)getpid();
|
return (unsigned long)getpid();
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxGetFreeMemory()
|
wxMemorySize wxGetFreeMemory()
|
||||||
{
|
{
|
||||||
#if defined(__LINUX__)
|
#if defined(__LINUX__)
|
||||||
// get it from /proc/meminfo
|
// get it from /proc/meminfo
|
||||||
@@ -881,10 +881,10 @@ long wxGetFreeMemory()
|
|||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return memFree;
|
return (wxMemorySize)memFree;
|
||||||
}
|
}
|
||||||
#elif defined(__SUN__) && defined(_SC_AVPHYS_PAGES)
|
#elif defined(__SUN__) && defined(_SC_AVPHYS_PAGES)
|
||||||
return sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
|
return (wxMemorySize)(sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE));
|
||||||
//#elif defined(__FREEBSD__) -- might use sysctl() to find it out, probably
|
//#elif defined(__FREEBSD__) -- might use sysctl() to find it out, probably
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -901,7 +901,7 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
|
|||||||
{
|
{
|
||||||
wxLogSysError( wxT("Failed to get file system statistics") );
|
wxLogSysError( wxT("Failed to get file system statistics") );
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// under Solaris we also have to use f_frsize field instead of f_bsize
|
// under Solaris we also have to use f_frsize field instead of f_bsize
|
||||||
@@ -922,9 +922,9 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
|
|||||||
*pFree = wxLongLong(fs.f_bavail) * blockSize;
|
*pFree = wxLongLong(fs.f_bavail) * blockSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
#else // !HAVE_STATFS && !HAVE_STATVFS
|
#else // !HAVE_STATFS && !HAVE_STATVFS
|
||||||
return FALSE;
|
return false;
|
||||||
#endif // HAVE_STATFS
|
#endif // HAVE_STATFS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,14 +937,14 @@ bool wxGetEnv(const wxString& var, wxString *value)
|
|||||||
// wxGetenv is defined as getenv()
|
// wxGetenv is defined as getenv()
|
||||||
wxChar *p = wxGetenv(var);
|
wxChar *p = wxGetenv(var);
|
||||||
if ( !p )
|
if ( !p )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if ( value )
|
if ( value )
|
||||||
{
|
{
|
||||||
*value = p;
|
*value = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSetEnv(const wxString& variable, const wxChar *value)
|
bool wxSetEnv(const wxString& variable, const wxChar *value)
|
||||||
@@ -994,13 +994,13 @@ extern "C" void wxFatalSignalHandler(wxTYPE_SA_HANDLER)
|
|||||||
bool wxHandleFatalExceptions(bool doit)
|
bool wxHandleFatalExceptions(bool doit)
|
||||||
{
|
{
|
||||||
// old sig handlers
|
// old sig handlers
|
||||||
static bool s_savedHandlers = FALSE;
|
static bool s_savedHandlers = false;
|
||||||
static struct sigaction s_handlerFPE,
|
static struct sigaction s_handlerFPE,
|
||||||
s_handlerILL,
|
s_handlerILL,
|
||||||
s_handlerBUS,
|
s_handlerBUS,
|
||||||
s_handlerSEGV;
|
s_handlerSEGV;
|
||||||
|
|
||||||
bool ok = TRUE;
|
bool ok = true;
|
||||||
if ( doit && !s_savedHandlers )
|
if ( doit && !s_savedHandlers )
|
||||||
{
|
{
|
||||||
// install the signal handler
|
// install the signal handler
|
||||||
@@ -1022,7 +1022,7 @@ bool wxHandleFatalExceptions(bool doit)
|
|||||||
wxLogDebug(_T("Failed to install our signal handler."));
|
wxLogDebug(_T("Failed to install our signal handler."));
|
||||||
}
|
}
|
||||||
|
|
||||||
s_savedHandlers = TRUE;
|
s_savedHandlers = true;
|
||||||
}
|
}
|
||||||
else if ( s_savedHandlers )
|
else if ( s_savedHandlers )
|
||||||
{
|
{
|
||||||
@@ -1036,7 +1036,7 @@ bool wxHandleFatalExceptions(bool doit)
|
|||||||
wxLogDebug(_T("Failed to uninstall our signal handler."));
|
wxLogDebug(_T("Failed to uninstall our signal handler."));
|
||||||
}
|
}
|
||||||
|
|
||||||
s_savedHandlers = FALSE;
|
s_savedHandlers = false;
|
||||||
}
|
}
|
||||||
//else: nothing to do
|
//else: nothing to do
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user