本文整理汇总了C++中cache_free函数的典型用法代码示例。如果您正苦于以下问题:C++ cache_free函数的具体用法?C++ cache_free怎么用?C++ cache_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cache_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: clean_old_connections
static void clean_old_connections(request_rec *r) {
upload_progress_node_t *prev = NULL;
ServerConfig *config = get_server_config(r);
CACHE_LOCK();
upload_progress_node_t *node = fetch_first_node(config);
while(node != NULL) {
if(time(NULL) > node->expires && node->done == 1 && node->expires != -1) {
/*clean*/
if(prev == NULL) {
/* head */
upload_progress_cache_t *cache = fetch_cache(config);
cache->head = fetch_node(config, node->next);
cache_free(config, node->key);
cache_free(config, node);
node = cache->head;
continue;
} else {
prev->next = node->next;
cache_free(config, node->key);
cache_free(config, node);
node = prev;
continue;
}
}
prev = node;
node = fetch_node(config, node->next);
}
CACHE_UNLOCK();
}
开发者ID:janx,项目名称:apache-upload-progress-module,代码行数:29,代码来源:mod_upload_progress.c
示例2: cachemgr_fini
/*
* Cleanup the caches and free all memory. Since OpenSSL certificates are
* being freed, this must be done before calling the OpenSSL cleanup methods.
* Also, it is not safe to call this while cachemgr_gc() is still running.
*/
void
cachemgr_fini(void)
{
cache_free(cachemgr_dsess);
cache_free(cachemgr_ssess);
cache_free(cachemgr_tgcrt);
cache_free(cachemgr_fkcrt);
}
开发者ID:cgroschupp,项目名称:sslsplit,代码行数:13,代码来源:cachemgr.c
示例3: cyclon_parse_data
static int cyclon_parse_data(struct peersampler_context *context, const uint8_t *buff, int len)
{
cache_check(context->local_cache);
if (len) {
const struct topo_header *h = (const struct topo_header *)buff;
struct peer_cache *remote_cache;
struct peer_cache *sent_cache = NULL;
if (h->protocol != MSG_TYPE_TOPOLOGY) {
fprintf(stderr, "Peer Sampler: Wrong protocol!\n");
return -1;
}
context->bootstrap = false;
remote_cache = entries_undump(buff + sizeof(struct topo_header), len - sizeof(struct topo_header));
if (h->type == CYCLON_QUERY) {
sent_cache = rand_cache(context->local_cache, context->sent_entries);
cyclon_reply(context->pc, remote_cache, sent_cache);
context->dst = NULL;
}
cache_check(context->local_cache);
cache_add_cache(context->local_cache, remote_cache);
cache_free(remote_cache);
if (sent_cache) {
cache_add_cache(context->local_cache, sent_cache);
cache_free(sent_cache);
} else {
if (context->flying_cache) {
cache_add_cache(context->local_cache, context->flying_cache);
cache_free(context->flying_cache);
context->flying_cache = NULL;
}
}
}
if (time_to_send(context)) {
if (context->flying_cache) {
cache_add_cache(context->local_cache, context->flying_cache);
cache_free(context->flying_cache);
context->flying_cache = NULL;
}
cache_update(context->local_cache);
context->dst = last_peer(context->local_cache);
if (context->dst == NULL) {
return 0;
}
context->dst = nodeid_dup(context->dst);
cache_del(context->local_cache, context->dst);
context->flying_cache = rand_cache(context->local_cache, context->sent_entries - 1);
return cyclon_query(context->pc, context->flying_cache, context->dst);
}
cache_check(context->local_cache);
return 0;
}
开发者ID:HunterChen,项目名称:GRAPES,代码行数:57,代码来源:cyclon.c
示例4: main
int main()
{
cache_head_t cache;
init_cache(&cache, 8);
long long *data = cache_malloc(&cache);
*data = 111111111;
cache_free(&cache, data);
data = cache_malloc(&cache);
cache_free(&cache, data);
return 0;
}
开发者ID:yuyang0,项目名称:yaspider,代码行数:11,代码来源:cache.c
示例5: upload_progress_destroy_cache
void upload_progress_destroy_cache(ServerConfig *config) {
upload_progress_cache_t *cache = fetch_cache(config);
upload_progress_node_t *node, *temp;
cache_free(config, cache);
node = fetch_node(config, cache->head);
while(node != NULL) {
temp = fetch_node(config, node->next);
cache_free(config, node);
node = temp;
}
}
开发者ID:janx,项目名称:apache-upload-progress-module,代码行数:13,代码来源:mod_upload_progress.c
示例6: xconv_free
xconv_t *
xconv_free (xconv_t *xc) /*{{{*/
{
if (xc) {
if (xc -> lower)
cache_free (xc -> lower);
if (xc -> upper)
cache_free (xc -> upper);
if (xc -> title)
cache_free (xc -> title);
free (xc);
}
return NULL;
}/*}}}*/
开发者ID:OrangeCountySEOMarketing,项目名称:openemm,代码行数:14,代码来源:xml.c
示例7: cache_reuse_test
static enum test_return cache_reuse_test(void)
{
int ii;
cache_t *cache = cache_create("test", sizeof(uint32_t), sizeof(char*),
NULL, NULL);
char *ptr = cache_alloc(cache);
cache_free(cache, ptr);
for (ii = 0; ii < 100; ++ii) {
char *p = cache_alloc(cache);
assert(p == ptr);
cache_free(cache, ptr);
}
cache_destroy(cache);
return TEST_PASS;
}
开发者ID:bcui6611,项目名称:moxi,代码行数:15,代码来源:testapp.c
示例8: rdp_guac_client_free_handler
int rdp_guac_client_free_handler(guac_client* client) {
rdp_guac_client_data* guac_client_data =
(rdp_guac_client_data*) client->data;
freerdp* rdp_inst = guac_client_data->rdp_inst;
rdpChannels* channels = rdp_inst->context->channels;
/* Clean up RDP client */
freerdp_channels_close(channels, rdp_inst);
freerdp_channels_free(channels);
freerdp_disconnect(rdp_inst);
freerdp_clrconv_free(((rdp_freerdp_context*) rdp_inst->context)->clrconv);
cache_free(rdp_inst->context->cache);
freerdp_free(rdp_inst);
/* Clean up filesystem, if allocated */
if (guac_client_data->filesystem != NULL)
guac_rdp_fs_free(guac_client_data->filesystem);
/* Free SVC list */
guac_common_list_free(guac_client_data->available_svc);
/* Free client data */
guac_common_clipboard_free(guac_client_data->clipboard);
guac_common_surface_free(guac_client_data->default_surface);
free(guac_client_data);
return 0;
}
开发者ID:Huangyan9188,项目名称:guacamole-server,代码行数:31,代码来源:guac_handlers.c
示例9: cleanup_cache_mem
static apr_status_t cleanup_cache_mem(void *sconfv)
{
cache_object_t *obj;
mem_cache_conf *co = (mem_cache_conf*) sconfv;
if (!co) {
return APR_SUCCESS;
}
if (!co->cache_cache) {
return APR_SUCCESS;
}
if (sconf->lock) {
apr_thread_mutex_lock(sconf->lock);
}
obj = cache_pop(co->cache_cache);
while (obj) {
/* Iterate over the cache and clean up each unreferenced entry */
if (!apr_atomic_dec32(&obj->refcount)) {
cleanup_cache_object(obj);
}
obj = cache_pop(co->cache_cache);
}
/* Cache is empty, free the cache table */
cache_free(co->cache_cache);
if (sconf->lock) {
apr_thread_mutex_unlock(sconf->lock);
}
return APR_SUCCESS;
}
开发者ID:Alivx,项目名称:apache2nginx,代码行数:32,代码来源:mod_mem_cache.c
示例10: main
/* Perform various actions on a cache and check it's statistics. */
int main() {
cache_t cache = CACHE_INIT;
char *data;
char *data1 = "data1";
size_t dlen;
uint8_t i;
char *key1 = "key1";
uint32_t ttl;
if (!cache_init(&cache, 512))
return 1;
for (i = 1; i < UINT8_MAX; i++) {
cache_set(&cache, key1, strlen(key1), data1, strlen(data1), CACHE_MAX_TTL);
}
cache_get(&cache, key1, strlen(key1), &dlen, &ttl);
if (cache.stats.get != 1)
return 2;
if (cache.stats.set != 254)
return 3;
if (cache.stats.motion != (CACHE_HEADER_SIZE + 9) * cache.stats.set)
return 4;
cache_free(&cache);
return 0;
}
开发者ID:dpejesh,项目名称:libsv-common,代码行数:30,代码来源:cache_stats.c
示例11: wf_context_free
void wf_context_free(freerdp* instance, rdpContext* context)
{
if (context->cache)
cache_free(context->cache);
freerdp_channels_free(context->channels);
}
开发者ID:akboom,项目名称:FreeRDP,代码行数:7,代码来源:wf_interface.c
示例12: main
main()
{
CACHE *cache;
char cmd[2];
int val, *pval;
/* Print some instructions. */
printf("This program demonstrates the various cache manipulation\n");
printf("routines supplied by this package. Although this program\n");
printf("manipulates a cache of integers, data of any type and size\n");
printf("(and not just integers) are supported by the routines. See\n");
printf("the man page for more information.\n\n");
printf("We illustrate a cache with a maximum size of 3 entries.\n\n");
/* Allocate a new cache. */
cache = cache_init(MAX_ELEMENTS);
print_cache(cache);
/* Get some commands. */
printf("\n(e)nter new element, (c)heck for element; (q)uit: ");
while (scanf("%1s", cmd) != EOF) {
switch (cmd[0]) {
case 'e':
printf("Value (int) to enter: ");
if (scanf("%d", &val)) {
/* We ignore the return code here, but in practice,
* we may fail (with a return code of NULL).
*/
cache_enter(cache, &val, sizeof(val), &pval);
if (pval != NULL) {
printf("%d was removed to make room.\n", *pval);
}
}
break;
case 'c':
printf("Value (int) to check for: ");
if (scanf("%d", &val)) {
pval = (int *) cache_check(cache, (char *) &val, match);
if (pval != NULL) {
printf("%d found!\n", *pval);
}
else {
printf("Not found.\n");
}
}
break;
case 'q':
cache_free(cache, CACHE_DEALLOC);
exit(0);
break;
default:
printf("'%s' not a recognized command!\n", cmd);
break;
}
print_cache(cache);
printf("\n(e)nter new element, (c)heck for element; (q)uit: ");
}
exit(0);
}
开发者ID:liei,项目名称:ttk4145,代码行数:60,代码来源:cachetest.c
示例13: aic_init_driver
static struct event_entry* aic_init_driver(void)
{
struct aic_entry *e = calloc(1, sizeof(struct aic_entry));
if (e == NULL) return NULL;
NEOERR *err;
e->base.name = (unsigned char*)strdup(PLUGIN_NAME);
e->base.ksize = strlen(PLUGIN_NAME);
e->base.process_driver = aic_process_driver;
e->base.stop_driver = aic_stop_driver;
char *dbsn = hdf_get_value(g_cfg, CONFIG_PATH".dbsn", NULL);
err = mdb_init(&e->db, dbsn);
JUMP_NOK(err, error);
e->cd = cache_create(hdf_get_int_value(g_cfg, CONFIG_PATH".numobjs", 1024), 0);
if (e->cd == NULL) {
wlog("init cache failure");
goto error;
}
return (struct event_entry*)e;
error:
if (e->base.name) free(e->base.name);
if (e->db) mdb_destroy(e->db);
if (e->cd) cache_free(e->cd);
free(e);
return NULL;
}
开发者ID:kingiol,项目名称:cmoon,代码行数:30,代码来源:mevent_aic.c
示例14: new_sample_callback
static GstFlowReturn new_sample_callback (GstAppSink * sink, gpointer user_data)
{
GstBuffer *buffer;
GstSample *sample;
Encoder *encoder = (Encoder *)user_data;
*(encoder->output->heartbeat) = gst_clock_get_time (encoder->system_clock);
sample = gst_app_sink_pull_sample (GST_APP_SINK (sink));
buffer = gst_sample_get_buffer (sample);
sem_wait (encoder->output->semaphore);
(*(encoder->output->total_count)) += gst_buffer_get_size (buffer);
/* update head_addr, free enough memory for current buffer. */
while (cache_free (encoder) < gst_buffer_get_size (buffer) + 12) { /* timestamp + gop size = 12 */
move_head (encoder);
}
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
/*
* random access point found.
* write previous gop size to 4 bytes reservation,
* write current gop timestamp,
* reserve 4 bytes for size of current gop,
*/
if (encoder->mqdes == -1) {
/* no m3u8 output */
move_last_rap (encoder, buffer);
} else if (GST_BUFFER_PTS (buffer) == encoder->last_running_time) {
gchar *msg;
move_last_rap (encoder, buffer);
msg = g_strdup_printf ("%lu", encoder->last_segment_duration);
if (mq_send (encoder->mqdes, msg, strlen (msg), 1) == -1) {
GST_ERROR ("mq_send error: %s", g_strerror (errno));
}
g_free (msg);
encoder->last_running_time = GST_CLOCK_TIME_NONE;
}
}
/* udpstreaming? */
if (encoder->udpstreaming) {
udp_streaming (encoder, buffer);
}
/*
* copy buffer to cache.
* update tail_addr
*/
copy_buffer (encoder, buffer);
sem_post (encoder->output->semaphore);
gst_sample_unref (sample);
return GST_FLOW_OK;
}
开发者ID:csdanping,项目名称:gstreamill,代码行数:60,代码来源:encoder.c
示例15: conn_cleanup
void
conn_cleanup(struct conn *c)
{
ASSERT(c != NULL);
if (c->item != NULL) {
item_remove(c->item);
c->item = NULL;
}
while (c->ileft > 0) {
item_remove(*(c->icurr));
c->ileft--;
c->icurr++;
}
while (c->sleft > 0) {
cache_free(c->thread->suffix_cache, *(c->scurr));
c->sleft--;
c->scurr++;
}
if (c->write_and_free != NULL) {
mc_free(c->write_and_free);
}
}
开发者ID:AllenDou,项目名称:twemcache,代码行数:26,代码来源:mc_connection.c
示例16: skeleton_init_driver
static EventEntry* skeleton_init_driver(void)
{
struct skeleton_entry *e = calloc(1, sizeof(struct skeleton_entry));
if (e == NULL) return NULL;
NEOERR *err;
e->base.name = (unsigned char*)strdup(PLUGIN_NAME);
e->base.ksize = strlen(PLUGIN_NAME);
e->base.process_driver = skeleton_process_driver;
e->base.stop_driver = skeleton_stop_driver;
//mevent_add_timer(&e->base.timers, 60, true, hint_timer_up_term);
//char *s = hdf_get_value(g_cfg, CONFIG_PATH".dbsn", NULL);
//err = mdb_init(&e->db, s);
//JUMP_NOK(err, error);
e->cd = cache_create(hdf_get_int_value(g_cfg, CONFIG_PATH".numobjs", 1024), 0);
if (e->cd == NULL) {
wlog("init cache failure");
goto error;
}
return (EventEntry*)e;
error:
if (e->base.name) free(e->base.name);
if (e->db) mdb_destroy(e->db);
if (e->cd) cache_free(e->cd);
free(e);
return NULL;
}
开发者ID:adderly,项目名称:cmoon,代码行数:31,代码来源:mevent_skeleton.c
示例17: env_close
void env_close(struct env *e)
{
cache_free(e->cache);
status_free(e->status);
txnmgr_free(e->txnmgr);
xfree(e->dir);
xfree(e);
}
开发者ID:yqingp,项目名称:testness,代码行数:8,代码来源:db.c
示例18: cache_destroy
/* destroy a cache */
int cache_destroy(const char *file) {
Cache *tmp;
tmp = cache_search(file);
if (tmp == NULL)
return(0);
cache_free(tmp);
return(1);
}
开发者ID:Hexasoft,项目名称:WebFS,代码行数:10,代码来源:cache.c
示例19: kpathsea_finish
/* Sadly, quite a lot of the freeing is not safe:
it seems there are literals used all over. */
void
kpathsea_finish (kpathsea kpse)
{
#if KPATHSEA_CAN_FREE
int i;
kpse_format_info_type f;
#endif /* KPATHSEA_CAN_FREE */
if (kpse==NULL)
return;
#if KPATHSEA_CAN_FREE
/* free internal stuff */
hash_free (kpse->cnf_hash);
hash_free (kpse->db);
hash_free (kpse->alias_db);
str_list_free(&kpse->db_dir_list);
hash_free (kpse->link_table);
cache_free (kpse->the_cache, kpse->cache_length);
hash_free (kpse->map);
string_free (kpse->map_path);
string_free (kpse->elt);
/*string_free (kpse->path);*/
if (kpse->log_file != (FILE *)NULL)
fclose(kpse->log_file);
string_free (kpse->invocation_name);
string_free (kpse->invocation_short_name);
string_free (kpse->program_name);
string_free (kpse->fallback_font);
string_free (kpse->fallback_resolutions_string);
if(kpse->fallback_resolutions != NULL)
free(kpse->fallback_resolutions);
for (i = 0; i != kpse_last_format; ++i) {
f = kpse->format_info[i];
/*string_free ((string)f.path);*/
string_free ((string)f.override_path);
string_free ((string)f.client_path);
/*string_free ((string)f.cnf_path);*/
}
if (kpse->missfont != (FILE *)NULL)
fclose(kpse->missfont);
for (i = 0; i < (int)kpse->expansion_len; i++) {
string_free (kpse->expansions[i].var);
}
free (kpse->expansions);
if (kpse->saved_env!=NULL) {
for (i = 0; i != kpse->saved_count; ++i)
string_free (kpse->saved_env[i]);
free (kpse->saved_env);
}
#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
if (kpse->suffixlist != NULL) {
char **p;
for p = kpse->suffixlist; *p; p++)
free (*p);
free (kpse->suffixlist);
}
开发者ID:QQ1350995917,项目名称:pdftex.js,代码行数:59,代码来源:kpathsea.c
示例20: skeleton_stop_driver
static void skeleton_stop_driver(EventEntry *entry)
{
struct skeleton_entry *e = (struct skeleton_entry*)entry;
/*
* e->base.name, e->base will free by mevent_stop_driver()
*/
mdb_destroy(e->db);
cache_free(e->cd);
}
开发者ID:adderly,项目名称:cmoon,代码行数:10,代码来源:mevent_skeleton.c
注:本文中的cache_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论