version 1.4, 2006/01/30 16:16:46
|
version 1.5, 2006/03/15 23:13:58
|
|
|
| |
#include <cstring> | #include <cstring> |
#include "Buffer.h" | #include "Buffer.h" |
|
#include "Pegasus/Common/InternalException.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
static inline BufferRep* _allocate(size_t cap) | static inline BufferRep* _allocate(size_t cap) |
{ | { |
BufferRep* rep = (BufferRep*)malloc(sizeof(BufferRep) + cap); | BufferRep* rep = (BufferRep*)malloc(sizeof(BufferRep) + cap); |
|
if (!rep) |
|
{ |
|
throw PEGASUS_STD(bad_alloc)(); |
|
} |
rep->cap = cap; | rep->cap = cap; |
return rep; | return rep; |
} | } |
|
|
static inline BufferRep* _reallocate(BufferRep* rep, size_t cap) | static inline BufferRep* _reallocate(BufferRep* rep, size_t cap) |
{ | { |
rep = (BufferRep*)realloc(rep, sizeof(BufferRep) + cap); | rep = (BufferRep*)realloc(rep, sizeof(BufferRep) + cap); |
|
if (!rep) |
|
{ |
|
throw PEGASUS_STD(bad_alloc)(); |
|
} |
rep->cap = cap; | rep->cap = cap; |
return rep; | return rep; |
} | } |