Diff for /libaitio/src/Attic/mem.c between versions 1.1.4.3 and 1.1.4.5

version 1.1.4.3, 2012/05/23 11:49:35 version 1.1.4.5, 2012/05/27 09:57:27
Line 402  mpool_free(mpool_t * __restrict mp, void * __restrict  Line 402  mpool_free(mpool_t * __restrict mp, void * __restrict 
         int idx;          int idx;
         struct tagAlloc *m, *tmp;          struct tagAlloc *m, *tmp;
   
           assert(tmp);
         if (!mp) {          if (!mp) {
                 io_SetErr(EINVAL, "Pool not specified");                  io_SetErr(EINVAL, "Pool not specified");
                 return -1;                  return -1;
         }          }
         /* check address range & sentinel */          /* check address range & sentinel */
           assert(!MEM_BADADDR(data) && !MEM_CORRUPT(data));
         if (MEM_BADADDR(data) || MEM_CORRUPT(data)) {          if (MEM_BADADDR(data) || MEM_CORRUPT(data)) {
                 io_SetErr(EFAULT, "Corrupted memory address");                  io_SetErr(EFAULT, "Corrupted memory address");
                 return -2;                  return -2;
Line 497  mpool_free2(mpool_t * __restrict mp, u_int size, const Line 499  mpool_free2(mpool_t * __restrict mp, u_int size, const
 }  }
   
 /*  /*
    * mpool_strdup() - String duplicate
    *
    * @mp = Memory pool
    * @str = String
    * @memname = Memory name
    * return: NULL error or !=NULL new string
    */
   char *
   mpool_strdup(mpool_t * __restrict mp, const char *str, const char *memname)
   {
           char *s = NULL;
           u_int len;
   
           if (!mp) {
                   io_SetErr(EINVAL, "Pool not specified");
                   return NULL;
           }
           if (!str) {
                   io_SetErr(EINVAL, "String is NULL");
                   return NULL;
           } else
                   len = strlen(str) + 1;
   
           s = mpool_malloc(mp, len, memname);
           if (!s)
                   return NULL;
           else
                   memcpy(s, str, len);
   
           return s;
   }
   
   /*
  * mpool_getmembynam() Find allocated memory block by size and memory name   * mpool_getmembynam() Find allocated memory block by size and memory name
  *   *
  * @mp = Memory pool   * @mp = Memory pool
Line 628  mpool_statistics(mpool_t * __restrict mp, mpool_stat_c Line 663  mpool_statistics(mpool_t * __restrict mp, mpool_stat_c
   
                 cb(1 << (i + MEM_MIN_BUCKET), act, inact);                  cb(1 << (i + MEM_MIN_BUCKET), act, inact);
         }          }
   }
   
   /* ----------------------------------------------------------- */
   
   /*
    * mpool_xmalloc() - malloc wrapper
    *
    * @size = Size
    * return: NULL error or !=NULL ok allocated memory
    */
   void *
   mpool_xmalloc(size_t size)
   {
           return mpool_malloc(io_mpool, size, NULL);
   }
   
   /*
    * mpool_xcalloc() - calloc wrapper
    *
    * @num = number of elements
    * @size = Size of element
    * return: NULL error or !=NULL ok allocated memory
    */
   void *
   mpool_xcalloc(size_t num, size_t size)
   {
           return mpool_malloc(io_mpool, num * size, NULL);
   }
   
   /*
    * mpool_xrealloc() - realloc wrapper
    *
    * @data = Allocated memory data
    * @newsize = New size of memory block
    * return: NULL error or !=NULL new reallocated memory block
    */
   void *
   mpool_xrealloc(void * __restrict data, size_t newsize)
   {
           return mpool_realloc(io_mpool, data, newsize, NULL);
   }
   
   /*
    * mpool_xfree() - free wrapper
    *
    * @data = Allocated memory data
    * return: none
    */
   void
   mpool_xfree(void * __restrict data)
   {
           mpool_free(io_mpool, data, 0);
   }
   
   /*
    * mpool_xstrdup() - strdup wrapper
    *
    * @str = string
    * return: =NULL error or !=NULL new allocated string
    */
   char *
   mpool_xstrdup(const char *str)
   {
           return mpool_strdup(io_mpool, str, NULL);
 }  }

Removed from v.1.1.4.3  
changed lines
  Added in v.1.1.4.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>