Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use posix_fallocate to set file size.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 26 Oct 2020 23:14:05 +0000 (00:14 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 27 Oct 2020 22:43:08 +0000 (23:43 +0100)
src/smpi/internals/smpi_shared.cpp

index 869f72d..2ffc282 100644 (file)
@@ -208,11 +208,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     smpi_shared_malloc_bogusfile = mkstemp(name);
     XBT_DEBUG("bogusfile         : %s\n", name);
     unlink(name);
-    const char* dumb = new char[smpi_shared_malloc_blocksize](); // zero initialized
-    ssize_t err = write(smpi_shared_malloc_bogusfile, dumb, smpi_shared_malloc_blocksize);
-    if(err<0)
+    int err = posix_fallocate(smpi_shared_malloc_bogusfile, 0, smpi_shared_malloc_blocksize);
+    if (err != 0)
       xbt_die("Could not write bogus file for shared malloc");
-    delete[] dumb;
   }
 
   int mmap_base_flag = MAP_FIXED | MAP_SHARED | MAP_POPULATE;