forked from objectcomputing/mFAST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallocator.cpp
More file actions
23 lines (21 loc) · 697 Bytes
/
allocator.cpp
File metadata and controls
23 lines (21 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (c) 2016, Huang-Ming Huang, Object Computing, Inc.
// All rights reserved.
//
// This file is part of mFAST.
// See the file license.txt for licensing information.
#include "allocator.h"
#include <new>
#include "allocator_utils.h"
#include <cstring>
namespace mfast {
std::size_t allocator::reallocate(void *&pointer, std::size_t old_size,
std::size_t new_size) {
// make the new_size at least 64 bytes
new_size = align(static_cast<std::size_t>(new_size), 64);
void *old_pointer = pointer;
pointer = this->allocate(new_size);
std::memcpy(pointer, old_pointer, old_size);
this->deallocate(old_pointer, old_size);
return new_size;
}
}