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