X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fmisc.c;h=c2c85e400067b206a849aa016d7685de687c83b7;hb=c020bbb83dd5b52a353fa867d7746a43eb5e6ffc;hp=2c01f36401e0e7eed881a71f23b5e1f4ab2baa3e;hpb=3dc317d10b44cc6b75db10ac194966ad8114d390;p=rocksndiamonds.git diff --git a/src/misc.c b/src/misc.c index 2c01f364..c2c85e40 100644 --- a/src/misc.c +++ b/src/misc.c @@ -27,6 +27,9 @@ #include "random.h" #include "joystick.h" +/* maximal allowed length of a command line option */ +#define MAX_OPTION_LEN 256 + static unsigned long mainCounter(int mode) { static struct timeval base_time = { 0, 0 }; @@ -226,12 +229,23 @@ char *getHomeDir() char *getPath2(char *path1, char *path2) { - char *complete_path = checked_malloc(strlen(path1) + strlen(path2) + 2); + char *complete_path = checked_malloc(strlen(path1) + 1 + + strlen(path2) + 1); sprintf(complete_path, "%s/%s", path1, path2); return complete_path; } +char *getPath3(char *path1, char *path2, char *path3) +{ + char *complete_path = checked_malloc(strlen(path1) + 1 + + strlen(path2) + 1 + + strlen(path3) + 1); + + sprintf(complete_path, "%s/%s/%s", path1, path2, path3); + return complete_path; +} + char *getStringCopy(char *s) { char *s_copy = checked_malloc(strlen(s) + 1);