Ejemplo n.º 1
0
inline void* MemoryManager::smartMalloc(size_t nbytes) {
  auto const nbytes_padded = nbytes + sizeof(SmallNode);
  if (LIKELY(nbytes_padded) <= kMaxSmartSize) {
    auto const ptr = static_cast<SmallNode*>(smartMallocSize(nbytes_padded));
    ptr->padbytes = nbytes_padded;
    ptr->kind = HeaderKind::SmallMalloc;
    return ptr + 1;
  }
  return smartMallocBig(nbytes);
}
Ejemplo n.º 2
0
inline void* MemoryManager::smartMalloc(size_t nbytes) {
  nbytes += sizeof(SmallNode);
  if (UNLIKELY(nbytes > kMaxSmartSize)) {
    return smartMallocBig(nbytes);
  }

  auto const ptr = static_cast<SmallNode*>(smartMallocSize(nbytes));
  ptr->padbytes = nbytes;
  return ptr + 1;
}