(root)/
glib-2.79.0/
glib/
deprecated/
gallocator.c
       1  /*
       2   * This library is free software; you can redistribute it and/or
       3   * modify it under the terms of the GNU Lesser General Public
       4   * License as published by the Free Software Foundation; either
       5   * version 2.1 of the License, or (at your option) any later version.
       6   *
       7   * This library is distributed in the hope that it will be useful,
       8   * but WITHOUT ANY WARRANTY; without even the implied warranty of
       9   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      10   * Lesser General Public License for more details.
      11   *
      12   * You should have received a copy of the GNU Lesser General Public
      13   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
      14   */
      15  
      16  #include "config.h"
      17  
      18  /* we know we are deprecated here, no need for warnings */
      19  #ifndef GLIB_DISABLE_DEPRECATION_WARNINGS
      20  #define GLIB_DISABLE_DEPRECATION_WARNINGS
      21  #endif
      22  
      23  #include "gallocator.h"
      24  
      25  #include <glib/gmessages.h>
      26  #include <glib/gslice.h>
      27  
      28  struct _GMemChunk {
      29    guint alloc_size;           /* the size of an atom */
      30  };
      31  
      32  GMemChunk*
      33  g_mem_chunk_new (const gchar *name,
      34                   gint         atom_size,
      35                   gsize        area_size,
      36                   gint         type)
      37  {
      38    GMemChunk *mem_chunk;
      39  
      40    g_return_val_if_fail (atom_size > 0, NULL);
      41  
      42    mem_chunk = g_slice_new (GMemChunk);
      43    mem_chunk->alloc_size = atom_size;
      44  
      45    return mem_chunk;
      46  }
      47  
      48  void
      49  g_mem_chunk_destroy (GMemChunk *mem_chunk)
      50  {
      51    g_return_if_fail (mem_chunk != NULL);
      52  
      53    g_slice_free (GMemChunk, mem_chunk);
      54  }
      55  
      56  gpointer
      57  g_mem_chunk_alloc (GMemChunk *mem_chunk)
      58  {
      59    g_return_val_if_fail (mem_chunk != NULL, NULL);
      60  
      61    return g_slice_alloc (mem_chunk->alloc_size);
      62  }
      63  
      64  gpointer
      65  g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
      66  {
      67    g_return_val_if_fail (mem_chunk != NULL, NULL);
      68  
      69    return g_slice_alloc0 (mem_chunk->alloc_size);
      70  }
      71  
      72  void
      73  g_mem_chunk_free (GMemChunk *mem_chunk,
      74                    gpointer   mem)
      75  {
      76    g_return_if_fail (mem_chunk != NULL);
      77  
      78    g_slice_free1 (mem_chunk->alloc_size, mem);
      79  }
      80  
      81  GAllocator*
      82  g_allocator_new (const gchar *name,
      83                   guint        n_preallocs)
      84  {
      85    /* some (broken) GAllocator uses depend on non-NULL allocators */
      86    return (void *) 1;
      87  }
      88  
      89  void g_allocator_free           (GAllocator *allocator) { }
      90  
      91  void g_mem_chunk_clean          (GMemChunk *mem_chunk)  { }
      92  void g_mem_chunk_reset          (GMemChunk *mem_chunk)  { }
      93  void g_mem_chunk_print          (GMemChunk *mem_chunk)  { }
      94  void g_mem_chunk_info           (void)                  { }
      95  void g_blow_chunks              (void)                  { }
      96  
      97  void g_list_push_allocator      (GAllocator *allocator) { }
      98  void g_list_pop_allocator       (void)                  { }
      99  
     100  void g_slist_push_allocator     (GAllocator *allocator) { }
     101  void g_slist_pop_allocator      (void)                  { }
     102  
     103  void g_node_push_allocator      (GAllocator *allocator) { }
     104  void g_node_pop_allocator       (void)                  { }