Exemplo n.º 1
0
void
bson_zero_free (void  *mem,  /* IN */
                size_t size) /* IN */
{
   if (BSON_LIKELY (mem)) {
      memset (mem, 0, size);
      gMemVtable.free (mem);
   }
}
Exemplo n.º 2
0
void *
bson_malloc (size_t num_bytes) /* IN */
{
   void *mem;

   if (!(mem = gMemVtable.malloc (num_bytes))) {
      abort ();
   }

   return mem;
}
Exemplo n.º 3
0
void *
bson_malloc0 (size_t num_bytes) /* IN */
{
   void *mem = NULL;

   if (BSON_LIKELY (num_bytes)) {
      if (BSON_UNLIKELY (!(mem = gMemVtable.calloc (1, num_bytes)))) {
         abort ();
      }
   }

   return mem;
}
Exemplo n.º 4
0
void *
bson_realloc (void   *mem,        /* IN */
              size_t  num_bytes)  /* IN */
{
   /*
    * Not all platforms are guaranteed to free() the memory if a call to
    * realloc() with a size of zero occurs. Windows, Linux, and FreeBSD do,
    * however, OS X does not.
    */
   if (BSON_UNLIKELY (num_bytes == 0)) {
      gMemVtable.free (mem);
      return NULL;
   }

   mem = gMemVtable.realloc (mem, num_bytes);

   if (BSON_UNLIKELY (!mem)) {
      abort ();
   }

   return mem;
}
Exemplo n.º 5
0
void *
bson_malloc (size_t num_bytes) /* IN */
{
   void *mem = NULL;

   if (BSON_LIKELY (num_bytes)) {
      if (BSON_UNLIKELY (!(mem = gMemVtable.malloc (num_bytes)))) {
         fprintf (stderr, "Failure to allocate memory in bson_malloc(). errno: %d.\n", errno);
         abort ();
      }
   }

   return mem;
}
Exemplo n.º 6
0
void
bson_free (void *mem) /* IN */
{
   gMemVtable.free (mem);
}