Hello.
I have a question.
Can i replace the function "VirtualAlloc" to the function
"HeapAlloc"in the following code from v8?
If not, why?



void* OS::Allocate(const size_t requested,
                   size_t* allocated,
                   bool executable) {
  // VirtualAlloc rounds allocated size to page size automatically.
  size_t msize = RoundUp(requested, GetPageSize());

  // Windows XP SP2 allows Data Excution Prevention (DEP).
  int prot = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
  LPVOID mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE,
prot);
  if (mbase == NULL) {
    LOG(StringEvent("OS::Allocate", "VirtualAlloc failed"));
    return NULL;
  }

  ASSERT(IsAligned(reinterpret_cast<size_t>(mbase),
OS::AllocateAlignment()));

  *allocated = msize;
  UpdateAllocatedSpaceLimits(mbase, msize);
  return mbase;
}
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to