forked from Mirrors/privacore-open-source-search-engine
Encapsulate SafeBuf more
This commit is contained in:
2
Json.cpp
2
Json.cpp
@ -5,7 +5,7 @@ class JsonItem *Json::addNewItem () {
|
||||
|
||||
JsonItem *ji = (JsonItem *)m_sb.getBufPtr();
|
||||
|
||||
if ( m_sb.m_length + (int32_t)sizeof(JsonItem) > m_sb.m_capacity ) {
|
||||
if(m_sb.getAvail() < (int32_t)sizeof(JsonItem)) {
|
||||
log("json: preventing buffer breach");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ bool Profiler::init() {
|
||||
// if ( ! m_quickpollMissBuf.reserve ( 20000 ) )
|
||||
// return false;
|
||||
|
||||
if ( m_ipBuf.m_capacity <= 0 &&
|
||||
if ( m_ipBuf.getCapacity() <= 0 &&
|
||||
! m_ipBuf.reserve ( 5000000 , "profbuf" ) )
|
||||
return false;
|
||||
|
||||
@ -942,8 +942,7 @@ Profiler::getStackFrame() {
|
||||
// return;
|
||||
|
||||
// the lines calling functions
|
||||
if ( g_profiler.m_ipBuf.m_length + 8*32 >=
|
||||
g_profiler.m_ipBuf.m_capacity )
|
||||
if ( g_profiler.m_ipBuf.getAvail() <= 8*32 )
|
||||
return;
|
||||
|
||||
// support 64-bit
|
||||
|
@ -237,9 +237,9 @@ public:
|
||||
const char& operator[](int32_t i) const;
|
||||
|
||||
public:
|
||||
int32_t m_capacity;
|
||||
int32_t m_length;
|
||||
private:
|
||||
int32_t m_capacity;
|
||||
char *m_buf;
|
||||
bool m_usingStack;
|
||||
const char *m_label;
|
||||
|
2
Wiki.cpp
2
Wiki.cpp
@ -91,8 +91,6 @@ bool Wiki::loadText ( int32_t fileSize ) {
|
||||
if ( ! sb.catFile(ff2) ) return false;
|
||||
|
||||
sb.pushChar('\0');
|
||||
// should not have reallocated too much
|
||||
if ( sb.length() + 100 < sb.m_capacity ) { g_process.shutdownAbort(true); }
|
||||
|
||||
char *buf = sb.getBufStart();
|
||||
int32_t size = sb.length() - 1;
|
||||
|
Reference in New Issue
Block a user