diff --git a/src/gifenc.c b/src/gifenc.c index c74998adf..b81cd97ae 100644 --- a/src/gifenc.c +++ b/src/gifenc.c @@ -63,9 +63,10 @@ new_trie(int degree, int *nkeys) static void del_trie(Node *root, int degree) { + int i; if (!root) return; - for (int i = 0; i < degree; i++) + for (i = 0; i < degree; i++) del_trie(root->children[i], degree); free(root); } diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 894df2602..33d01e29a 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -1319,7 +1319,9 @@ static void handle_motioners(int oldpos_x, int oldpos_y, int motioner, int hatmo static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_y, SDL_Rect real_r_tools); char * get_xdg_user_dir(const char * dir_type, const char * fallback); - +#ifdef WIN32 +extern char * GetUserImageDir(void); +#endif /* Magic tools API and tool handles: */ @@ -22843,12 +22845,15 @@ static void setup_config(char *argv[]) else { /* FIXME: Need assist for: - * _WIN32 * __BEOS__ * __HAIKU__ * __APPLE__ */ +#ifdef WIN32 + picturesdir = GetUserImageDir(); +#else picturesdir = get_xdg_user_dir("PICTURES", "Pictures"); +#endif safe_snprintf(str, sizeof(str), "%s/TuxPaint", picturesdir); free(picturesdir); exportdir = strdup(str); diff --git a/src/win32_print.c b/src/win32_print.c index 0b5c989ed..bb2c7a549 100644 --- a/src/win32_print.c +++ b/src/win32_print.c @@ -597,6 +597,27 @@ char *GetSystemFontDir(void) return strdup("C:\\WINDOWS\\FONTS"); } +/** + * + * Returns heap string containing user's image directory. + * + * @return user's image dir + */ +char *GetUserImageDir(void) +{ + char path[MAX_PATH]; + const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; + const char *option = "My Pictures"; + HRESULT hr = S_OK; + + if (SUCCEEDED(hr = ReadRegistry(key, option, path, sizeof(path)))) + { + remove_slash(path); + return strdup(path); + } + return strdup("C:\\Pictures"); +} + /* Returns heap string containing user temp directory. E.g. C:\Documents and Settings\jfp\Local Settings\Temp