src/os/bsd/vm/perfMemory_bsd.cpp

changeset 3900
d2a62e0f25eb
parent 3156
f08d439fab8c
child 4153
b9a9ed0f8eeb
     1.1 --- a/src/os/bsd/vm/perfMemory_bsd.cpp	Wed Jun 27 15:23:36 2012 +0200
     1.2 +++ b/src/os/bsd/vm/perfMemory_bsd.cpp	Thu Jun 28 17:03:16 2012 -0400
     1.3 @@ -126,7 +126,7 @@
     1.4        }
     1.5      }
     1.6    }
     1.7 -  FREE_C_HEAP_ARRAY(char, destfile);
     1.8 +  FREE_C_HEAP_ARRAY(char, destfile, mtInternal);
     1.9  }
    1.10  
    1.11  
    1.12 @@ -153,7 +153,7 @@
    1.13    const char* tmpdir = os::get_temp_directory();
    1.14    const char* perfdir = PERFDATA_NAME;
    1.15    size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
    1.16 -  char* dirname = NEW_C_HEAP_ARRAY(char, nbytes);
    1.17 +  char* dirname = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
    1.18  
    1.19    // construct the path name to user specific tmp directory
    1.20    snprintf(dirname, nbytes, "%s/%s_%s", tmpdir, perfdir, user);
    1.21 @@ -246,7 +246,7 @@
    1.22    if (bufsize == -1)
    1.23      bufsize = 1024;
    1.24  
    1.25 -  char* pwbuf = NEW_C_HEAP_ARRAY(char, bufsize);
    1.26 +  char* pwbuf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
    1.27  
    1.28    // POSIX interface to getpwuid_r is used on LINUX
    1.29    struct passwd* p;
    1.30 @@ -278,14 +278,14 @@
    1.31                                       "pw_name zero length");
    1.32        }
    1.33      }
    1.34 -    FREE_C_HEAP_ARRAY(char, pwbuf);
    1.35 +    FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
    1.36      return NULL;
    1.37    }
    1.38  
    1.39 -  char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1);
    1.40 +  char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1, mtInternal);
    1.41    strcpy(user_name, p->pw_name);
    1.42  
    1.43 -  FREE_C_HEAP_ARRAY(char, pwbuf);
    1.44 +  FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
    1.45    return user_name;
    1.46  }
    1.47  
    1.48 @@ -328,7 +328,7 @@
    1.49    // to determine the user name for the process id.
    1.50    //
    1.51    struct dirent* dentry;
    1.52 -  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname));
    1.53 +  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
    1.54    errno = 0;
    1.55    while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) {
    1.56  
    1.57 @@ -338,7 +338,7 @@
    1.58      }
    1.59  
    1.60      char* usrdir_name = NEW_C_HEAP_ARRAY(char,
    1.61 -                              strlen(tmpdirname) + strlen(dentry->d_name) + 2);
    1.62 +                 strlen(tmpdirname) + strlen(dentry->d_name) + 2, mtInternal);
    1.63      strcpy(usrdir_name, tmpdirname);
    1.64      strcat(usrdir_name, "/");
    1.65      strcat(usrdir_name, dentry->d_name);
    1.66 @@ -346,7 +346,7 @@
    1.67      DIR* subdirp = os::opendir(usrdir_name);
    1.68  
    1.69      if (subdirp == NULL) {
    1.70 -      FREE_C_HEAP_ARRAY(char, usrdir_name);
    1.71 +      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
    1.72        continue;
    1.73      }
    1.74  
    1.75 @@ -357,13 +357,13 @@
    1.76      // symlink can be exploited.
    1.77      //
    1.78      if (!is_directory_secure(usrdir_name)) {
    1.79 -      FREE_C_HEAP_ARRAY(char, usrdir_name);
    1.80 +      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
    1.81        os::closedir(subdirp);
    1.82        continue;
    1.83      }
    1.84  
    1.85      struct dirent* udentry;
    1.86 -    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name));
    1.87 +    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
    1.88      errno = 0;
    1.89      while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
    1.90  
    1.91 @@ -372,7 +372,7 @@
    1.92          int result;
    1.93  
    1.94          char* filename = NEW_C_HEAP_ARRAY(char,
    1.95 -                            strlen(usrdir_name) + strlen(udentry->d_name) + 2);
    1.96 +                 strlen(usrdir_name) + strlen(udentry->d_name) + 2, mtInternal);
    1.97  
    1.98          strcpy(filename, usrdir_name);
    1.99          strcat(filename, "/");
   1.100 @@ -381,13 +381,13 @@
   1.101          // don't follow symbolic links for the file
   1.102          RESTARTABLE(::lstat(filename, &statbuf), result);
   1.103          if (result == OS_ERR) {
   1.104 -           FREE_C_HEAP_ARRAY(char, filename);
   1.105 +           FREE_C_HEAP_ARRAY(char, filename, mtInternal);
   1.106             continue;
   1.107          }
   1.108  
   1.109          // skip over files that are not regular files.
   1.110          if (!S_ISREG(statbuf.st_mode)) {
   1.111 -          FREE_C_HEAP_ARRAY(char, filename);
   1.112 +          FREE_C_HEAP_ARRAY(char, filename, mtInternal);
   1.113            continue;
   1.114          }
   1.115  
   1.116 @@ -397,23 +397,23 @@
   1.117            if (statbuf.st_ctime > oldest_ctime) {
   1.118              char* user = strchr(dentry->d_name, '_') + 1;
   1.119  
   1.120 -            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
   1.121 -            oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1);
   1.122 +            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user, mtInternal);
   1.123 +            oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
   1.124  
   1.125              strcpy(oldest_user, user);
   1.126              oldest_ctime = statbuf.st_ctime;
   1.127            }
   1.128          }
   1.129  
   1.130 -        FREE_C_HEAP_ARRAY(char, filename);
   1.131 +        FREE_C_HEAP_ARRAY(char, filename, mtInternal);
   1.132        }
   1.133      }
   1.134      os::closedir(subdirp);
   1.135 -    FREE_C_HEAP_ARRAY(char, udbuf);
   1.136 -    FREE_C_HEAP_ARRAY(char, usrdir_name);
   1.137 +    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
   1.138 +    FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
   1.139    }
   1.140    os::closedir(tmpdirp);
   1.141 -  FREE_C_HEAP_ARRAY(char, tdbuf);
   1.142 +  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
   1.143  
   1.144    return(oldest_user);
   1.145  }
   1.146 @@ -434,7 +434,7 @@
   1.147    // add 2 for the file separator and a null terminator.
   1.148    size_t nbytes = strlen(dirname) + UINT_CHARS + 2;
   1.149  
   1.150 -  char* name = NEW_C_HEAP_ARRAY(char, nbytes);
   1.151 +  char* name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
   1.152    snprintf(name, nbytes, "%s/%d", dirname, vmid);
   1.153  
   1.154    return name;
   1.155 @@ -472,7 +472,7 @@
   1.156  static void remove_file(const char* dirname, const char* filename) {
   1.157  
   1.158    size_t nbytes = strlen(dirname) + strlen(filename) + 2;
   1.159 -  char* path = NEW_C_HEAP_ARRAY(char, nbytes);
   1.160 +  char* path = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
   1.161  
   1.162    strcpy(path, dirname);
   1.163    strcat(path, "/");
   1.164 @@ -480,7 +480,7 @@
   1.165  
   1.166    remove_file(path);
   1.167  
   1.168 -  FREE_C_HEAP_ARRAY(char, path);
   1.169 +  FREE_C_HEAP_ARRAY(char, path, mtInternal);
   1.170  }
   1.171  
   1.172  
   1.173 @@ -517,7 +517,7 @@
   1.174    // opendir/readdir.
   1.175    //
   1.176    struct dirent* entry;
   1.177 -  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname));
   1.178 +  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
   1.179    errno = 0;
   1.180    while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
   1.181  
   1.182 @@ -556,7 +556,7 @@
   1.183      errno = 0;
   1.184    }
   1.185    os::closedir(dirp);
   1.186 -  FREE_C_HEAP_ARRAY(char, dbuf);
   1.187 +  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
   1.188  }
   1.189  
   1.190  // make the user specific temporary directory. Returns true if
   1.191 @@ -723,11 +723,11 @@
   1.192  
   1.193    fd = create_sharedmem_resources(dirname, filename, size);
   1.194  
   1.195 -  FREE_C_HEAP_ARRAY(char, user_name);
   1.196 -  FREE_C_HEAP_ARRAY(char, dirname);
   1.197 +  FREE_C_HEAP_ARRAY(char, user_name, mtInternal);
   1.198 +  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
   1.199  
   1.200    if (fd == -1) {
   1.201 -    FREE_C_HEAP_ARRAY(char, filename);
   1.202 +    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
   1.203      return NULL;
   1.204    }
   1.205  
   1.206 @@ -743,7 +743,7 @@
   1.207        warning("mmap failed -  %s\n", strerror(errno));
   1.208      }
   1.209      remove_file(filename);
   1.210 -    FREE_C_HEAP_ARRAY(char, filename);
   1.211 +    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
   1.212      return NULL;
   1.213    }
   1.214  
   1.215 @@ -869,7 +869,7 @@
   1.216    // store file, we don't follow them when attaching either.
   1.217    //
   1.218    if (!is_directory_secure(dirname)) {
   1.219 -    FREE_C_HEAP_ARRAY(char, dirname);
   1.220 +    FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
   1.221      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
   1.222                "Process not found");
   1.223    }
   1.224 @@ -884,9 +884,9 @@
   1.225    strcpy(rfilename, filename);
   1.226  
   1.227    // free the c heap resources that are no longer needed
   1.228 -  if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
   1.229 -  FREE_C_HEAP_ARRAY(char, dirname);
   1.230 -  FREE_C_HEAP_ARRAY(char, filename);
   1.231 +  if (luser != user) FREE_C_HEAP_ARRAY(char, luser, mtInternal);
   1.232 +  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
   1.233 +  FREE_C_HEAP_ARRAY(char, filename, mtInternal);
   1.234  
   1.235    // open the shared memory file for the give vmid
   1.236    fd = open_sharedmem_file(rfilename, file_flags, CHECK);

mercurial