--- old/src/windows/demo/jvmti/hprof/hprof_md.c 2013-03-07 12:38:45.864642162 +0100 +++ new/src/windows/demo/jvmti/hprof/hprof_md.c 2013-03-07 12:38:45.692642154 +0100 @@ -368,42 +368,32 @@ } static void dll_build_name(char* buffer, size_t buflen, - const char* pname, const char* fname) { - // Loosley based on os_windows.cpp + const char* paths, const char* fname) { + char *path, *paths_copy, *next_token; - char *pathname = (char *)pname; - *buffer = '\0'; - while (strlen(pathname) > 0) { - char *p = strchr(pathname, ';'); - if (p == NULL) { - p = pathname + strlen(pathname); - } - /* check for NULL path */ - if (p == pathname) { - continue; - } - if (*(p-1) == ':' || *(p-1) == '\\') { - (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname), - pathname, fname); - } else { - (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname), - pathname, fname); - } + paths_copy = strdup(paths); + if (paths_copy == NULL) { + return; + } + + next_token = NULL; + path = strtok_s(paths_copy, ";", &next_token); + + while(path != NULL) { + _snprintf(buffer, buflen, "%s\\%s.dll", path, fname); if (_access(buffer, 0) == 0) { break; } - if (*p == '\0') { - pathname = p; - } else { - pathname = p + 1; - } *buffer = '\0'; + path = strtok_s(NULL, ";", &next_token); } + + free(paths_copy); } /* Build a machine dependent library name out of a path and file name. */ void -md_build_library_name(char *holder, int holderlen, char *pname, char *fname) +md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname) { int pnamelen;