src/hotspot/share/runtime/os.cpp
changeset 58083 9046db64ca39
parent 58048 8009a9c36251
child 58084 cddef3bde924
equal deleted inserted replaced
58081:8b08eaf9a0eb 58083:9046db64ca39
   289 bool os::dll_locate_lib(char *buffer, size_t buflen,
   289 bool os::dll_locate_lib(char *buffer, size_t buflen,
   290                         const char* pname, const char* fname) {
   290                         const char* pname, const char* fname) {
   291   bool retval = false;
   291   bool retval = false;
   292 
   292 
   293   size_t fullfnamelen = strlen(JNI_LIB_PREFIX) + strlen(fname) + strlen(JNI_LIB_SUFFIX);
   293   size_t fullfnamelen = strlen(JNI_LIB_PREFIX) + strlen(fname) + strlen(JNI_LIB_SUFFIX);
   294   char* fullfname = (char*)NEW_C_HEAP_ARRAY(char, fullfnamelen + 1, mtInternal);
   294   char* fullfname = NEW_C_HEAP_ARRAY(char, fullfnamelen + 1, mtInternal);
   295   if (dll_build_name(fullfname, fullfnamelen + 1, fname)) {
   295   if (dll_build_name(fullfname, fullfnamelen + 1, fname)) {
   296     const size_t pnamelen = pname ? strlen(pname) : 0;
   296     const size_t pnamelen = pname ? strlen(pname) : 0;
   297 
   297 
   298     if (pnamelen == 0) {
   298     if (pnamelen == 0) {
   299       // If no path given, use current working directory.
   299       // If no path given, use current working directory.
  1327   *elements = (size_t)0;
  1327   *elements = (size_t)0;
  1328   if (path == NULL || strlen(path) == 0 || file_name_length == (size_t)NULL) {
  1328   if (path == NULL || strlen(path) == 0 || file_name_length == (size_t)NULL) {
  1329     return NULL;
  1329     return NULL;
  1330   }
  1330   }
  1331   const char psepchar = *os::path_separator();
  1331   const char psepchar = *os::path_separator();
  1332   char* inpath = (char*)NEW_C_HEAP_ARRAY(char, strlen(path) + 1, mtInternal);
  1332   char* inpath = NEW_C_HEAP_ARRAY(char, strlen(path) + 1, mtInternal);
  1333   if (inpath == NULL) {
  1333   if (inpath == NULL) {
  1334     return NULL;
  1334     return NULL;
  1335   }
  1335   }
  1336   strcpy(inpath, path);
  1336   strcpy(inpath, path);
  1337   size_t count = 1;
  1337   size_t count = 1;
  1340   while (p != NULL) {
  1340   while (p != NULL) {
  1341     count++;
  1341     count++;
  1342     p++;
  1342     p++;
  1343     p = strchr(p, psepchar);
  1343     p = strchr(p, psepchar);
  1344   }
  1344   }
  1345   char** opath = (char**) NEW_C_HEAP_ARRAY(char*, count, mtInternal);
  1345 
       
  1346   char** opath = NEW_C_HEAP_ARRAY(char*, count, mtInternal);
  1346 
  1347 
  1347   // do the actual splitting
  1348   // do the actual splitting
  1348   p = inpath;
  1349   p = inpath;
  1349   for (size_t i = 0 ; i < count ; i++) {
  1350   for (size_t i = 0 ; i < count ; i++) {
  1350     size_t len = strcspn(p, os::path_separator());
  1351     size_t len = strcspn(p, os::path_separator());
  1354       vm_exit_during_initialization("The VM tried to use a path that exceeds the maximum path length for "
  1355       vm_exit_during_initialization("The VM tried to use a path that exceeds the maximum path length for "
  1355                                     "this system. Review path-containing parameters and properties, such as "
  1356                                     "this system. Review path-containing parameters and properties, such as "
  1356                                     "sun.boot.library.path, to identify potential sources for this path.");
  1357                                     "sun.boot.library.path, to identify potential sources for this path.");
  1357     }
  1358     }
  1358     // allocate the string and add terminator storage
  1359     // allocate the string and add terminator storage
  1359     char* s  = (char*)NEW_C_HEAP_ARRAY_RETURN_NULL(char, len + 1, mtInternal);
  1360     char* s  = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len + 1, mtInternal);
       
  1361 
  1360     if (s == NULL) {
  1362     if (s == NULL) {
  1361       // release allocated storage before returning null
  1363       // release allocated storage before returning null
  1362       free_array_of_char_arrays(opath, i++);
  1364       free_array_of_char_arrays(opath, i++);
  1363       return NULL;
  1365       return NULL;
  1364     }
  1366     }