Skip to content

Commit

Permalink
Revert removal of POOL_MEM::max_size method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Sep 7, 2014
1 parent cb4df9a commit f9d54c6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dird/bsr.c
Expand Up @@ -89,7 +89,7 @@ static void print_bsr_item(POOL_MEM *pool_buf, const char *fmt, ...)
POOL_MEM item(PM_MESSAGE);

while (1) {
maxlen = item.size() - 1;
maxlen = item.max_size() - 1;
va_start(arg_ptr, fmt);
len = bvsnprintf(item.c_str(), maxlen, fmt, arg_ptr);
va_end(arg_ptr);
Expand Down
16 changes: 15 additions & 1 deletion src/lib/mem_pool.c
Expand Up @@ -630,6 +630,20 @@ int pm_memcpy(POOL_MEM &pm, const char *data, int32_t n)

/* ============== CLASS POOL_MEM ============== */

/*
* Return the size of a memory buffer
*/
int32_t POOL_MEM::max_size()
{
int32_t size;
char *cp = mem;

cp -= HEAD_SIZE;
size = ((struct abufhead *)cp)->ablen;

return size;
}

void POOL_MEM::realloc_pm(int32_t size)
{
char *cp = mem;
Expand All @@ -638,7 +652,7 @@ void POOL_MEM::realloc_pm(int32_t size)

P(mutex);
cp -= HEAD_SIZE;
buf = (char *)realloc(cp, size+HEAD_SIZE);
buf = (char *)realloc(cp, size + HEAD_SIZE);
if (buf == NULL) {
V(mutex);
Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes\n"), size);
Expand Down
1 change: 1 addition & 0 deletions src/lib/mem_pool.h
Expand Up @@ -96,6 +96,7 @@ class POOL_MEM {
mem = check_pool_memory_size(mem, size);
return mem;
}
int32_t max_size();
void realloc_pm(int32_t size);
int strcpy(const char *str);
int strcat(const char *str);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/message.c
Expand Up @@ -1549,7 +1549,7 @@ int Mmsg(POOL_MEM &pool_buf, const char *fmt, ...)
va_list ap;

while (1) {
maxlen = pool_buf.size() - 1;
maxlen = pool_buf.max_size() - 1;
va_start(ap, fmt);
len = bvsnprintf(pool_buf.c_str(), maxlen, fmt, ap);
va_end(ap);
Expand Down

0 comments on commit f9d54c6

Please sign in to comment.