/usr/include/lru_cache.h is in libregfi-dev 1.0.1+svn287-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | /*
* Copyright (C) 2008-2010 Timothy D. Morgan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
/**
* @file
*
* A data structure which approximates a least recently used (LRU) cache.
* Implemented as a basic randomized hash table.
*/
#ifndef LRU_CACHE_H
#define LRU_CACHE_H
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <talloc.h>
#include "compat.h"
struct lru_cache_element;
typedef struct lru_cache_element lru_cache_element;
struct lru_cache_element
{
void* index;
uint32_t index_len;
void* data;
lru_cache_element* next;
lru_cache_element* older;
lru_cache_element* newer;
};
/** XXX: document this. */
typedef struct _lru_cache
{
uint32_t secret;
uint32_t num_keys;
uint32_t num_buckets;
uint32_t max_keys;
lru_cache_element* oldest;
lru_cache_element* newest;
lru_cache_element** table;
bool talloc_data;
} lru_cache;
/**
* XXX: finish documenting.
*/
_EXPORT()
lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret);
/**
* XXX: finish documenting.
*/
_EXPORT()
lru_cache* lru_cache_create_ctx(void* talloc_ctx, uint32_t max_keys,
uint32_t secret, bool talloc_data);
/**
* XXX: finish documenting.
*/
_EXPORT()
void lru_cache_destroy(lru_cache* ht);
/**
* XXX: finish documenting.
*/
_EXPORT()
bool lru_cache_update(lru_cache* ht, const void* index,
uint32_t index_len, void* data);
/**
* XXX: finish documenting.
*
* @return A pointer to data previously stored at index.
* If no data was found at index, NULL is returned.
*/
_EXPORT()
void* lru_cache_find(lru_cache* ht, const void* index,
uint32_t index_len);
/**
* XXX: finish documenting.
*
* Removes entry from table at index.
*
* @return A pointer to data that was there previously or NULL if no entry is
* at index.
*/
_EXPORT()
bool lru_cache_remove(lru_cache* ht, const void* index,
uint32_t index_len);
#endif
|