-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "out of buffers" crash #3783
Changes from 1 commit
b6421d4
6b557d2
c11d12f
9c91079
73728d7
aebbe22
70ac7db
d1aa39b
93e4bd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ struct MemoryPool | |
MemoryPool( size_t chunks ) : | ||
m_chunks( chunks ) | ||
{ | ||
m_free = reinterpret_cast<char*>(MemoryHelper::alignedMalloc( chunks )); | ||
m_free = reinterpret_cast<char*>( MemoryHelper::alignedMalloc( chunks ) ); | ||
memset( m_free, 1, chunks ); | ||
} | ||
|
||
|
@@ -109,17 +109,17 @@ struct MmAllocator | |
typedef T value_type; | ||
template< class U > struct rebind { typedef MmAllocator<U> other; }; | ||
|
||
T* allocate(std::size_t n) | ||
T* allocate( std::size_t n ) | ||
{ | ||
return reinterpret_cast<T*>( MemoryManager::alloc( sizeof(T) * n ) ); | ||
} | ||
|
||
void deallocate(T* p, std::size_t) | ||
void deallocate( T* p, std::size_t ) | ||
{ | ||
MemoryManager::free( p ); | ||
} | ||
|
||
typedef std::vector<T, MmAllocator<T> > vector; | ||
typedef std::vector<T, MmAllocator<T>> vector; | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These parts aren't used. Are there some reasons you leave them in our codebase? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I plan on using them at a later point in time. Using an Allocator class is the standard C++ way of having custom allocators, and should be preferred over using the macros
This has already been discussed by @Umcaruje and me in the comments here. C++03 doesn't allow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Well it's a vector, so why not call it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, but you used both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, no that's not intentional. |
||
|
||
|
@@ -143,7 +143,7 @@ static void operator delete[] ( void * ptr ) \ | |
} | ||
|
||
// for use in cases where overriding new/delete isn't a possibility | ||
#define MM_ALLOC( type, count ) reinterpret_cast<type*>(MemoryManager::alloc( sizeof( type ) * count )) | ||
#define MM_ALLOC( type, count ) reinterpret_cast<type*>( MemoryManager::alloc( sizeof( type ) * count ) ) | ||
// and just for symmetry... | ||
#define MM_FREE( ptr ) MemoryManager::free( ptr ) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the space here was removed again, have an error while compiling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, should have remembered from 73728d7