00001 /* 00002 * Copyright 2009 Red Hat Inc., Durham, North Carolina. 00003 * All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * Authors: 00020 * "Daniel Kopecek" <dkopecek@redhat.com> 00021 */ 00022 00023 #pragma once 00024 #ifndef ENCACHE_H 00025 #define ENCACHE_H 00026 00027 #include <pthread.h> 00028 #include <stdint.h> 00029 00030 #define ENCACHE_INIT_SIZE 24 00031 #define ENCACHE_ADD_SIZE 8 00032 00033 typedef struct { 00034 pthread_rwlock_t lock; 00035 SEXP_t **name; /* array of S-exp refs */ 00036 size_t real; /* number of cached names */ 00037 size_t size; /* pre-allocated size */ 00038 } encache_t; 00039 00043 encache_t *encache_new (void); 00044 00053 void encache_free (encache_t *cache); 00054 00063 SEXP_t *encache_add (encache_t *cache, const char *name); 00064 00072 SEXP_t *encache_get (encache_t *cache, const char *name); 00073 00081 SEXP_t *encache_ref (encache_t *cache, const char *name); 00082 00083 #endif /* ENCACHE_H */