epoc32/include/stdapis/glib-2.0/glib/gslice.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 gslice.h
     1 /* GLIB sliced memory - fast threaded memory chunk allocator
       
     2  * Copyright (C) 2005 Tim Janik
       
     3  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
       
     4  *
       
     5  * This library is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Lesser General Public
       
     7  * License as published by the Free Software Foundation; either
       
     8  * version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This library is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Lesser General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Lesser General Public
       
    16  * License along with this library; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 #ifndef __G_SLICE_H__
       
    21 #define __G_SLICE_H__
       
    22 
       
    23 #ifndef __G_MEM_H__
       
    24 #error Include <glib.h> instead of <gslice.h>
       
    25 #endif
       
    26 
       
    27 #include <glib/gtypes.h>
       
    28 
       
    29 G_BEGIN_DECLS
       
    30 
       
    31 /* slices - fast allocation/release of small memory blocks
       
    32  */
       
    33 IMPORT_C gpointer g_slice_alloc          	(gsize	  block_size) G_GNUC_MALLOC;
       
    34 IMPORT_C gpointer g_slice_alloc0         	(gsize    block_size) G_GNUC_MALLOC;
       
    35 IMPORT_C void     g_slice_free1          	(gsize    block_size,
       
    36 					 gpointer mem_block);
       
    37 IMPORT_C void     g_slice_free_chain_with_offset (gsize    block_size,
       
    38 					 gpointer mem_chain,
       
    39 					 gsize    next_offset);
       
    40 #define  g_slice_new(type)      ((type*) g_slice_alloc (sizeof (type)))
       
    41 #define  g_slice_new0(type)     ((type*) g_slice_alloc0 (sizeof (type)))
       
    42 /*       g_slice_free                   (MemoryBlockType,
       
    43  *	                                 MemoryBlockType *mem_block);
       
    44  *       g_slice_free_chain             (MemoryBlockType,
       
    45  *                                       MemoryBlockType *first_chain_block,
       
    46  *                                       memory_block_next_field);
       
    47  * pseudo prototypes for the macro
       
    48  * definitions following below.
       
    49  */
       
    50 
       
    51 /* we go through extra hoops to ensure type safety */
       
    52 #define g_slice_free(type, mem)				do {	\
       
    53   if (1) g_slice_free1 (sizeof (type), (mem));			\
       
    54   else   (void) ((type*) 0 == (mem)); 				\
       
    55 } while (0)
       
    56 #define g_slice_free_chain(type, mem_chain, next)	do {	\
       
    57   if (1) g_slice_free_chain_with_offset (sizeof (type),		\
       
    58                  (mem_chain), G_STRUCT_OFFSET (type, next)); 	\
       
    59   else   (void) ((type*) 0 == (mem_chain));			\
       
    60 } while (0)
       
    61 
       
    62 
       
    63 /* --- internal debugging API --- */
       
    64 typedef enum {
       
    65   G_SLICE_CONFIG_ALWAYS_MALLOC = 1,
       
    66   G_SLICE_CONFIG_BYPASS_MAGAZINES,
       
    67   G_SLICE_CONFIG_WORKING_SET_MSECS,
       
    68   G_SLICE_CONFIG_COLOR_INCREMENT,
       
    69   G_SLICE_CONFIG_CHUNK_SIZES,
       
    70   G_SLICE_CONFIG_CONTENTION_COUNTER
       
    71 } GSliceConfig;
       
    72 void     g_slice_set_config	   (GSliceConfig ckey, gint64 value);
       
    73 gint64   g_slice_get_config	   (GSliceConfig ckey);
       
    74 gint64*  g_slice_get_config_state  (GSliceConfig ckey, gint64 address, guint *n_values);
       
    75 
       
    76 G_END_DECLS
       
    77 
       
    78 #endif /* __G_SLICE_H__ */