libjf API reference guide

Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

jf_recind_pool.h

Go to the documentation of this file.
00001 /* 00002 * Copyright 2005 Tiian 00003 * {In real life Tiian is Christian Ferrari} 00004 * This file is part of "libjf" package. 00005 * 00006 * "libjf" is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * "libjf" is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with ; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 #ifndef JF_RECIND_POOL_H 00021 #define JF_RECIND_POOL_H 00022 00023 #include <jf/jf_config.h> 00024 00025 00026 00027 #include <jf/jf_recind_seq.h> 00028 00029 00030 00031 /* save old JF_TRACE_MODULE and set a new value */ 00032 #ifdef JF_TRACE_MODULE 00033 # define JF_TRACE_MODULE_SAVE JF_TRACE_MODULE 00034 # undef JF_TRACE_MODULE 00035 #else 00036 # undef JF_TRACE_MODULE_SAVE 00037 #endif /* JF_TRACE_MODULE */ 00038 #define JF_TRACE_MODULE JF_TRACE_MOD_LIB_RECIND_POOL 00039 00040 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif /* __cplusplus */ 00045 00046 00047 00053 typedef struct { 00057 size_t size; 00061 jf_recind_seq_t *array; 00062 } jf_recind_pool_t; 00063 00064 00065 00070 void jf_recind_pool_reset(jf_recind_pool_t *rip); 00071 00072 00073 00081 int jf_recind_pool_create(jf_recind_pool_t *rip, size_t size); 00082 00083 00084 00091 void jf_recind_pool_destroy(jf_recind_pool_t *rip); 00092 00093 00094 00100 static inline int jf_recind_pool_is_safe(const jf_recind_pool_t *rip) { 00101 return (rip->array != NULL && rip->size > 0) || 00102 (rip->array == NULL && rip->size == 0); } 00103 00104 00105 00112 static inline jf_recind_seq_t *jf_recind_pool_get_seq( 00113 const jf_recind_pool_t *rip, jf_word_t id) { 00114 if (id<0 || id>=rip->size) 00115 return NULL; 00116 return rip->array + id; 00117 } 00118 00119 00120 00126 static inline jf_word_t jf_recind_pool_get_size( 00127 const jf_recind_pool_t *rip) { 00128 return rip->size; } 00129 00130 00131 00132 #ifdef __cplusplus 00133 } 00134 #endif /* __cplusplus */ 00135 00136 00137 00138 /* restore old value of JF_TRACE_MODULE */ 00139 #ifdef JF_TRACE_MODULE_SAVE 00140 # undef JF_TRACE_MODULE 00141 # define JF_TRACE_MODULE JF_TRACE_MODULE_SAVE 00142 # undef JF_TRACE_MODULE_SAVE 00143 #endif /* JF_TRACE_MODULE_SAVE */ 00144 00145 00146 00147 #endif /* JF_RECIND_POOL_H */

Copyright 2005 © Tiian