using our own functions for strdup and _splitpath with the d_ prefix for all platforms for consistency
This commit is contained in:
parent
2c9ee20981
commit
d58e6fc38f
|
@ -3,6 +3,7 @@ D1X-Rebirth Changelog
|
|||
20120519
|
||||
--------
|
||||
arch/ogl/gr.c, arch/sdl/digi_mixer_music.c, arch/sdl/jukebox.c, editor/autosave.c, editor/func.c, include/strutil.h, main/bmread.c, main/gamecntl.c, main/gamesave.c, main/hash.c, main/hud.c, main/menu.c, main/mission.c, main/multi.c, main/net_udp.c, main/newmenu.c, main/piggy.c, main/playsave.c, main/scores.c, main/songs.c, main/text.c, main/titles.c, misc/args.c, misc/physfsx.c, misc/strutil.c, texmap/scanline.c, ui/file.c: using our own functions for stricmp, strnicmp, strlwr, strupr, strrev with a d_ prefix for all platforms for consistency
|
||||
editor/kmine.c, editor/mine.c, include/strutil.h, include/u_mem.h, main/gamesave.c, mem/mem.c, misc/strutil.c: using our own functions for strdup and _splitpath with the d_ prefix for all platforms for consistency
|
||||
|
||||
20120518
|
||||
--------
|
||||
|
|
|
@ -197,7 +197,7 @@ int med_save_situation(char * filename)
|
|||
|
||||
// Write mine name.
|
||||
// strcpy(mine_name, filename);
|
||||
_splitpath(filename, NULL, NULL, mine_name, NULL);
|
||||
d_splitpath(filename, NULL, NULL, mine_name, NULL);
|
||||
set_extension(mine_name, "min");
|
||||
PHYSFSX_printf(SaveFile, "%s\n", mine_name);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ int med_save_mine(char * filename)
|
|||
{
|
||||
#if 0 //ndef __linux__
|
||||
char fname[20];
|
||||
_splitpath( filename, NULL, NULL, fname, NULL );
|
||||
d_splitpath( filename, NULL, NULL, fname, NULL );
|
||||
|
||||
sprintf( ErrorMessage, \
|
||||
"ERROR: Cannot write to '%s'.\nYou probably need to check out a locked\nversion of the file. You should save\nthis under a different filename, and then\ncheck out a locked copy by typing\n\'co -l %s.lvl'\nat the DOS prompt.\n"
|
||||
|
|
|
@ -9,6 +9,7 @@ extern int d_strnicmp( const char *s1, const char *s2, int n );
|
|||
extern void d_strlwr( char *s1 );
|
||||
extern void d_strupr( char *s1 );
|
||||
extern void d_strrev( char *s1 );
|
||||
extern char *d_strdup(char *str);
|
||||
|
||||
// remove extension from filename, doesn't work with paths.
|
||||
void removeext(const char *filename, char *out);
|
||||
|
@ -16,9 +17,7 @@ void removeext(const char *filename, char *out);
|
|||
//give a filename a new extension, doesn't work with paths with no extension already there
|
||||
extern void change_filename_extension( char *dest, const char *src, char *new_ext );
|
||||
|
||||
#if !(defined(_WIN32))
|
||||
void _splitpath(char *name, char *drive, char *path, char *base, char *ext);
|
||||
#endif
|
||||
extern void _splitpath(char *name, char *drive, char *path, char *base, char *ext);
|
||||
|
||||
// create a growing 2D array with a single growing buffer for the text
|
||||
// this system is likely to cause less memory fragmentation than having one malloc'd buffer per string
|
||||
|
|
|
@ -37,7 +37,6 @@ extern char * mem_strdup(char * str, char * var, char * file, int line );
|
|||
#define d_calloc(n,size) mem_malloc((n*size),"Unknown", __FILE__,__LINE__, 1 )
|
||||
#define d_realloc(ptr,size) mem_realloc((ptr),(size),"Unknown", __FILE__,__LINE__ )
|
||||
#define d_free(ptr) do{ mem_free(ptr); ptr=NULL; } while(0)
|
||||
#define d_strdup(str) mem_strdup((str),"Unknown",__FILE__,__LINE__)
|
||||
|
||||
#define MALLOC( var, type, count ) (var=(type *)mem_malloc((count)*sizeof(type),#var, __FILE__,__LINE__,0 ))
|
||||
|
||||
|
@ -54,7 +53,6 @@ extern char *strdup(const char *str);
|
|||
#define d_calloc(n, size) calloc(n, size)
|
||||
#define d_realloc(ptr,size) realloc(ptr,size)
|
||||
#define d_free(ptr) do{ free(ptr); ptr=NULL; } while(0)
|
||||
#define d_strdup(str) strdup(str)
|
||||
|
||||
#define MALLOC( var, type, count ) (var=(type *)malloc((count)*sizeof(type)))
|
||||
|
||||
|
|
|
@ -1476,7 +1476,7 @@ int save_level_sub(char * filename, int compiled_version)
|
|||
char ErrorMessage[256];
|
||||
|
||||
char fname[20];
|
||||
_splitpath( temp_filename, NULL, NULL, fname, NULL );
|
||||
d_splitpath( temp_filename, NULL, NULL, fname, NULL );
|
||||
|
||||
sprintf( ErrorMessage, \
|
||||
"ERROR: Cannot write to '%s'.\nYou probably need to check out a locked\nversion of the file. You should save\nthis under a different filename, and then\ncheck out a locked copy by typing\n\'co -l %s.lvl'\nat the DOS prompt.\n"
|
||||
|
|
10
mem/mem.c
10
mem/mem.c
|
@ -276,16 +276,6 @@ void *mem_realloc(void * buffer, unsigned int size, char * var, char * filename,
|
|||
return newbuffer;
|
||||
}
|
||||
|
||||
char *mem_strdup(char *str, char *var, char *filename, int line)
|
||||
{
|
||||
char *newstr;
|
||||
|
||||
newstr = mem_malloc(strlen(str) + 1, var, filename, line, 0);
|
||||
strcpy(newstr, str);
|
||||
|
||||
return newstr;
|
||||
}
|
||||
|
||||
void mem_display_blocks()
|
||||
{
|
||||
int i, numleft;
|
||||
|
|
|
@ -126,6 +126,16 @@ void d_strrev( char *s1 )
|
|||
}
|
||||
}
|
||||
|
||||
char *d_strdup(char *str)
|
||||
{
|
||||
char *newstr;
|
||||
|
||||
newstr = d_malloc(strlen(str) + 1);
|
||||
strcpy(newstr, str);
|
||||
|
||||
return newstr;
|
||||
}
|
||||
|
||||
// remove extension from filename
|
||||
void removeext(const char *filename, char *out)
|
||||
{
|
||||
|
@ -163,8 +173,7 @@ void change_filename_extension( char *dest, const char *src, char *ext )
|
|||
strcpy(p+1,ext);
|
||||
}
|
||||
|
||||
#if !(defined(_WIN32))
|
||||
void _splitpath(char *name, char *drive, char *path, char *base, char *ext)
|
||||
void d_splitpath(char *name, char *drive, char *path, char *base, char *ext)
|
||||
{
|
||||
char *s, *p;
|
||||
|
||||
|
@ -214,7 +223,6 @@ void _splitpath(char *name, char *drive, char *path, char *base, char *ext)
|
|||
if (ext)
|
||||
strcpy(ext, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
// create a growing 2D array with a single growing buffer for the text
|
||||
// this system is likely to cause less memory fragmentation than having one malloc'd buffer per string
|
||||
|
|
Loading…
Reference in a new issue