]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/mem_pool.c
Add missing files for xattr and eliminate a few compiler complaints
[bacula/bacula] / bacula / src / lib / mem_pool.c
index d961c396c7aae88c35e5a0891998af05d1fb5666..e36f63df6a4b9c6e70b5043b3e5017bf2a5fb767 100644 (file)
@@ -95,7 +95,6 @@ struct abufhead {
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
-
 #ifdef SMARTALLOC
 
 #define HEAD_SIZE BALIGN(sizeof(struct abufhead))
@@ -154,7 +153,6 @@ POOLMEM *sm_get_memory(const char *fname, int lineno, int32_t size)
    return (POOLMEM *)(((char *)buf)+HEAD_SIZE);
 }
 
-
 /* Return the size of a memory buffer */
 int32_t sm_sizeof_pool_memory(const char *fname, int lineno, POOLMEM *obuf)
 {
@@ -233,7 +231,6 @@ void sm_free_pool_memory(const char *fname, int lineno, POOLMEM *obuf)
    V(mutex);
 }
 
-
 #else
 
 /* =========  NO SMARTALLOC  =========================================  */
@@ -284,7 +281,6 @@ POOLMEM *get_memory(int32_t size)
    return (POOLMEM *)(((char *)buf)+HEAD_SIZE);
 }
 
-
 /* Return the size of a memory buffer */
 int32_t sizeof_pool_memory(POOLMEM *obuf)
 {
@@ -295,8 +291,6 @@ int32_t sizeof_pool_memory(POOLMEM *obuf)
    return ((struct abufhead *)cp)->ablen;
 }
 
-
-
 /* Realloc pool memory buffer */
 POOLMEM *realloc_pool_memory(POOLMEM *obuf, int32_t size)
 {
@@ -321,7 +315,6 @@ POOLMEM *realloc_pool_memory(POOLMEM *obuf, int32_t size)
    return (POOLMEM *)(((char *)buf)+HEAD_SIZE);
 }
 
-
 POOLMEM *check_pool_memory_size(POOLMEM *obuf, int32_t size)
 {
    ASSERT(obuf);
@@ -361,10 +354,8 @@ void free_pool_memory(POOLMEM *obuf)
    Dmsg2(1800, "free_pool_memory %p pool=%d\n", buf, pool);
    V(mutex);
 }
-
 #endif /* SMARTALLOC */
 
-
 /*
  * Clean up memory pool periodically
  *
@@ -393,9 +384,6 @@ void garbage_collect_memory_pool()
    }
 }
 
-
-
-
 /* Release all pooled memory */
 void close_memory_pool()
 {
@@ -423,7 +411,6 @@ void close_memory_pool()
 }
 
 #ifdef DEBUG
-
 static const char *pool_name(int pool)
 {
    static const char *name[] = {"NoPool", "NAME  ", "FNAME ", "MSG   ", "EMSG  "};
@@ -452,7 +439,6 @@ void print_memory_pool_stats()
 void print_memory_pool_stats() {}
 #endif /* DEBUG */
 
-
 /*
  * Concatenate a string (str) onto a pool memory buffer pm
  *   Returns: length of concatenated string
@@ -483,7 +469,6 @@ int pm_strcat(POOLMEM *&pm, const char *str)
    return pmlen + len - 1;
 }
 
-
 int pm_strcat(POOLMEM *&pm, POOL_MEM &str)
 {
    int pmlen = strlen(pm);
@@ -507,7 +492,6 @@ int pm_strcat(POOL_MEM &pm, const char *str)
    return pmlen + len - 1;
 }
 
-
 /*
  * Copy a string (str) into a pool memory buffer pm
  *   Returns: length of string copied
@@ -545,7 +529,6 @@ int pm_strcpy(POOLMEM *&pm, POOL_MEM &str)
    return len - 1;
 }
 
-
 int pm_strcpy(POOL_MEM &pm, const char *str)
 {
    int len;
@@ -558,6 +541,38 @@ int pm_strcpy(POOL_MEM &pm, const char *str)
    return len - 1;
 }
 
+/*
+ * Copy data into a pool memory buffer pm
+ *   Returns: length of data copied
+ */
+int pm_memcpy(POOLMEM **pm, const void *data, size_t n)
+{
+   *pm = check_pool_memory_size(*pm, n);
+   memcpy(*pm, data, n);
+   return n;
+}
+
+int pm_memcpy(POOLMEM *&pm, const void *data, size_t n)
+{
+   pm = check_pool_memory_size(pm, n);
+   memcpy(pm, data, n);
+   return n;
+}
+
+int pm_memcpy(POOLMEM *&pm, POOL_MEM &data, size_t n)
+{
+   pm = check_pool_memory_size(pm, n);
+   memcpy(pm, data.c_str(), n);
+   return n;
+}
+
+int pm_memcpy(POOL_MEM &pm, const void *data, size_t n)
+{
+   pm.check_size(n);
+   memcpy(pm.c_str(), data, n);
+   return n;
+}
+
 /* ==============  CLASS POOL_MEM   ============== */
 
 /* Return the size of a memory buffer */
@@ -608,7 +623,6 @@ int POOL_MEM::strcat(const char *str)
    return pmlen + len - 1;
 }
 
-
 int POOL_MEM::strcpy(const char *str)
 {
    int len;