39#if !defined(WIN32) || defined(__GNUC__)
43 #define getcwd _getcwd
47#if defined __cplusplus
58 void *p =
xData_realloc( smr, NULL, size, forItem, file, line );
63 if( ( p != NULL ) && zero ) {
65 for( i = 0, l = (
long long *) p; i < (int)( size /
sizeof(
long long ) ); i++, l++ ) *l = 0;
67 for( i =
sizeof(
long long ) * i, c = (
char *) l; i < (int) size; i++, c++ ) *c = 0;
77 void *p = realloc( pOld, size );
79 if( ( p == NULL ) && ( smr != NULL ) ) {
80 smr_setMessageError( smr, NULL, file, line, -1,
" xData_realloc: failed to realloc size = %llu for variable %s\n",
81 (
unsigned long long) size, forItem );
91 if( p != NULL ) free( p );
104 if( ( c = (
char*)
xData_malloc( smr, strlen( s ) + 1, 0, forItem, file, line ) ) != NULL ) {
116 int n = strlen( fileName ) + 1, nCwd = 0;
118 char *absPath, cwd[4 * 1024 + 1] =
"", *p, *needle;
120 if( fileName[0] !=
'/' ) {
122 if( getcwd( cwd,
sizeof( cwd ) ) == NULL ) {
126 nCwd = strlen( cwd );
130 if( ( absPath = (
char*)
xData_malloc2( smr, n, 0,
"absPath" ) ) == NULL )
return( NULL );
131 if( fileName[0] !=
'/' ) {
132 strcpy( absPath, cwd );
133 strcat( absPath,
"/" );
134 strcat( absPath, fileName ); }
136 strcpy( absPath, fileName );
140 if( ( needle = strstr( absPath,
"/./" ) ) == NULL )
break;
142 for( needle += 2; *needle; p++, needle++ ) *p = *needle;
147 if( ( needle = strstr( absPath,
"/../" ) ) == NULL )
break;
149 while( ( p > absPath ) && ( *p !=
'/' ) ) p--;
150 if( *p !=
'/' )
break;
151 if( p == absPath )
break;
152 for( needle += 3; *needle; p++, needle++ ) *p = *needle;
161 const char *fmt, ... ) {
165 va_start( args, fmt );
171#if defined __cplusplus
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
void * xData_free(statusMessageReporting *smr, void *p)
char * xDataMisc_getAbsPath(statusMessageReporting *smr, const char *fileName)
char * xDataMisc_allocateCopyString(statusMessageReporting *smr, const char *s, const char *forItem, const char *routine, int line)
int xData_setMessageError_ReturnInt(int value, statusMessageReporting *smr, void *userData, const char *file, int line, int code, const char *fmt,...)
void * xData_malloc(statusMessageReporting *smr, size_t size, int zero, const char *forItem, const char *file, int line)
void * xData_realloc(statusMessageReporting *smr, void *pOld, size_t size, const char *forItem, const char *routine, int line)
#define xData_malloc2(smr, size, zero, forItem)