This commit is contained in:
Igor Pavlov
2005-05-30 00:00:00 +00:00
committed by Kornel Lesiński
parent 8c1b5c7b7e
commit 3c510ba80b
926 changed files with 40559 additions and 23519 deletions

View File

@@ -1,11 +1,9 @@
// Common/Buffer.h
#pragma once
#ifndef __COMMON_BUFFER_H
#define __COMMON_BUFFER_H
// #include "Common/Defs.h"
#include "Defs.h"
template <class T> class CBuffer
{
@@ -28,9 +26,15 @@ public:
size_t GetCapacity() const { return _capacity; }
void SetCapacity(size_t newCapacity)
{
T *newBuffer = new T[newCapacity];
if(_capacity > 0)
memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T));
T *newBuffer;
if (newCapacity > 0)
{
newBuffer = new T[newCapacity];
if(_capacity > 0)
memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T));
}
else
newBuffer = 0;
delete []_items;
_items = newBuffer;
_capacity = newCapacity;