cpp/src/plasma/dlmalloc.cc
// Create a buffer. This is creating a temporary file and then
// immediately unlinking it so we do not leave traces in the system.
Create a buffer. This is creating a temporary file and then
immediately unlinking it so we do not leave traces in the system.
Create a buffer . This is creating a temporary file and then immediately unlinking it so we do not leave traces in the system .
int create_buffer(int64_t size) {
  int fd;
  std::string file_template = plasma_config->directory;
#ifdef _WIN32
  if (!CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
                         (DWORD)((uint64_t)size >> (CHAR_BIT * sizeof(DWORD))),
                         (DWORD)(uint64_t)size, NULL)) {
    fd = -1;
  }
#else
  file_template += "/plasmaXXXXXX";
  std::vector<char> file_name(file_template.begin(), file_template.end());
  file_name.push_back('\0');
  fd = mkstemp(&file_name[0]);
  if (fd < 0) {
    ARROW_LOG(FATAL) << "create_buffer failed to open file " << &file_name[0];
    return -1;
  }
  if (unlink(&file_name[0]) != 0) {
    ARROW_LOG(FATAL) << "failed to unlink file " << &file_name[0];
    return -1;
  }
  if (!plasma_config->hugepages_enabled) {
    if (ftruncate(fd, (off_t)size) != 0) {
      ARROW_LOG(FATAL) << "failed to ftruncate file " << &file_name[0];
      return -1;
    }
  }
#endif
  return fd;
}
int create_buffer ( int64_t size ) { int fd ; std :: string file_template = plasma_config -> directory ; #ifdef _WIN32 if ( ! CreateFileMapping ( INVALID_HANDLE_VALUE , NULL , PAGE_READWRITE , ( DWORD ) ( ( uint64_t ) size >> ( CHAR_BIT * sizeof ( DWORD ) ) ) , ( DWORD ) ( uint64_t ) size , NULL ) ) { fd = -1 ; } #else file_template += " " ; std :: vector < char > file_name ( file_template . begin ( ) , file_template . end ( ) ) ; file_name . push_back ( ' \0 ' ) ; fd = mkstemp ( & file_name [ 0 ] ) ; if ( fd < 0 ) { ARROW_LOG ( FATAL ) << " " << & file_name [ 0 ] ; return -1 ; } if ( unlink ( & file_name [ 0 ] ) != 0 ) { ARROW_LOG ( FATAL ) << " " << & file_name [ 0 ] ; return -1 ; } if ( ! plasma_config -> hugepages_enabled ) { if ( ftruncate ( fd , ( off_t ) size ) != 0 ) { ARROW_LOG ( FATAL ) << " " << & file_name [ 0 ] ; return -1 ; } } #endif return fd ; }
Create a buffer.
Create a buffer .
// Immediately unlink the file so we do not leave traces in the system. // Increase the size of the file to the desired size. This seems not to be // needed for files that are backed by the huge page fs, see also // http://www.mail-archive.com/kvm-devel@lists.sourceforge.net/msg14737.html