Permalink
Browse files

Allocate memory for mmap_info as thread-shared

  • Loading branch information...
1 parent d30d4ab commit a4c2c0fd69870a41789c00892828db5d10c0100e @Leont committed Jun 4, 2010
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/File/Map.xs
View
@@ -239,7 +239,7 @@ static int mmap_free(pTHX_ SV* var, MAGIC* magic) {
MUTEX_DESTROY(&info->data_mutex);
MUTEX_UNLOCK(&info->count_mutex);
MUTEX_DESTROY(&info->count_mutex);
- Safefree(info);
+ PerlMemShared_free(info);
}
else {
if (msync(info->real_address, info->real_length, MS_ASYNC) == -1)
@@ -249,7 +249,7 @@ static int mmap_free(pTHX_ SV* var, MAGIC* magic) {
#else
if (munmap(info->real_address, info->real_length) == -1)
die_sys(aTHX_ "Could not unmap: %s");
- Safefree(info);
+ PerlMemShared_free(info);
#endif
SvREADONLY_off(var);
SvPVX(var) = NULL;
@@ -336,8 +336,7 @@ static void* do_mapping(pTHX_ size_t length, int prot, int flags, int fd, off_t
}
static struct mmap_info* initialize_mmap_info(void* address, size_t length, ptrdiff_t correction) {
- struct mmap_info* magical;
- New(0, magical, 1, struct mmap_info);
+ struct mmap_info* magical = PerlMemShared_malloc(sizeof *magical);
magical->real_address = address;
magical->fake_address = (char*)address + correction;
magical->real_length = length + correction;

0 comments on commit a4c2c0f

Please sign in to comment.