static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st) { int option; struct cache_entry *ce; /* Was the old index entry already up-to-date? */ if (old && !ce_stage(old) && !ce_match_stat(old, st, 0)) return 0; ce = make_empty_cache_entry(len); memcpy(ce->name, path, len); ce->ce_flags = create_ce_flags(0); ce->ce_namelen = len; fill_stat_cache_info(ce, st); ce->ce_mode = ce_mode_from_stat(old, st->st_mode); if (index_path(&ce->oid, path, st, info_only ? 0 : HASH_WRITE_OBJECT)) { cache_entry_free(ce); return -1; } option = allow_add ? ADD_CACHE_OK_TO_ADD : 0; option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0; if (add_cache_entry(ce, option)) { cache_entry_free(ce); return error("%s: cannot add to the index - missing --add option?", path); } return 0; }
static int do_reupdate(int ac, const char **av, const char *prefix, int prefix_length) { /* Read HEAD and run update-index on paths that are * merged and already different between index and HEAD. */ int pos; int has_head = 1; struct pathspec pathspec; parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD, prefix, av + 1); if (read_ref("HEAD", &head_oid)) /* If there is no HEAD, that means it is an initial * commit. Update everything in the index. */ has_head = 0; redo: for (pos = 0; pos < active_nr; pos++) { const struct cache_entry *ce = active_cache[pos]; struct cache_entry *old = NULL; int save_nr; char *path; if (ce_stage(ce) || !ce_path_match(ce, &pathspec, NULL)) continue; if (has_head) old = read_one_ent(NULL, &head_oid, ce->name, ce_namelen(ce), 0); if (old && ce->ce_mode == old->ce_mode && !oidcmp(&ce->oid, &old->oid)) { cache_entry_free(old); continue; /* unchanged */ } /* Be careful. The working tree may not have the * path anymore, in which case, under 'allow_remove', * or worse yet 'allow_replace', active_nr may decrease. */ save_nr = active_nr; path = xstrdup(ce->name); update_one(path); free(path); cache_entry_free(old); if (save_nr != active_nr) goto redo; } clear_pathspec(&pathspec); return 0; }
static CacheEntry * cache_entry_new (const GstVaapiDisplayInfo * di) { GstVaapiDisplayInfo *info; CacheEntry *entry; entry = g_slice_new (CacheEntry); if (!entry) return NULL; info = &entry->info; info->display = di->display; info->va_display = di->va_display; info->native_display = di->native_display; info->display_type = di->display_type; info->display_name = NULL; if (di->display_name) { info->display_name = g_strdup (di->display_name); if (!info->display_name) goto error; } return entry; /* ERRORS */ error: { cache_entry_free (entry); return NULL; } }
void avahi_wide_area_clear_cache(AvahiWideAreaLookupEngine *e) { assert(e); while (e->cache) cache_entry_free(e->cache); assert(e->cache_n_entries == 0); }
static void expiry_event(AvahiTimeEvent *te, void *userdata) { AvahiWideAreaCacheEntry *e = userdata; assert(te); assert(e); cache_entry_free(e); }
static void gst_vaapi_display_cache_finalize (GstVaapiDisplayCache * cache) { GList *l; if (cache->list) { for (l = cache->list; l != NULL; l = l->next) cache_entry_free (l->data); g_list_free (cache->list); cache->list = NULL; } g_rec_mutex_clear (&cache->mutex); }
/** * gst_vaapi_display_cache_remove: * @cache: the #GstVaapiDisplayCache * @display: the display to remove from cache * * Removes any cache entry that matches the specified #GstVaapiDisplay. */ void gst_vaapi_display_cache_remove (GstVaapiDisplayCache * cache, GstVaapiDisplay * display) { GList *m; m = cache_lookup_1 (cache, compare_display, display, GST_VAAPI_DISPLAY_TYPE_ANY); if (!m) return; cache_entry_free (m->data); cache->list = g_list_delete_link (cache->list, m); }
static void http_func(const char *content_type, GString *content_or_error, void *data) { CacheEntry *entry = data; GTimeVal now; g_assert(entry->pixbuf == NULL); g_get_current_time(&now); entry->last_attempt = now.tv_sec; if (content_type != NULL && content_or_error->len > 0) { entry->pixbuf = parse_pixbuf(entry->url, content_or_error); } if (entry->pixbuf) ADD_WEAK(&entry->pixbuf); /* if pixbuf is NULL we failed, otherwise we succeeded. * either way we invoke the callbacks. */ entry->loading = FALSE; cache_entry_invoke_callbacks(entry); /* note that this will immediately NULL the pixbuf if there were no * strong references added during the callbacks */ if (entry->pixbuf) g_object_unref(entry->pixbuf); if (entry->free_on_load) { cache_entry_free(entry); } }
static int unresolve_one(const char *path) { int namelen = strlen(path); int pos; int ret = 0; struct cache_entry *ce_2 = NULL, *ce_3 = NULL; /* See if there is such entry in the index. */ pos = cache_name_pos(path, namelen); if (0 <= pos) { /* already merged */ pos = unmerge_cache_entry_at(pos); if (pos < active_nr) { const struct cache_entry *ce = active_cache[pos]; if (ce_stage(ce) && ce_namelen(ce) == namelen && !memcmp(ce->name, path, namelen)) return 0; } /* no resolve-undo information; fall back */ } else { /* If there isn't, either it is unmerged, or * resolved as "removed" by mistake. We do not * want to do anything in the former case. */ pos = -pos-1; if (pos < active_nr) { const struct cache_entry *ce = active_cache[pos]; if (ce_namelen(ce) == namelen && !memcmp(ce->name, path, namelen)) { fprintf(stderr, "%s: skipping still unmerged path.\n", path); goto free_return; } } } /* Grab blobs from given path from HEAD and MERGE_HEAD, * stuff HEAD version in stage #2, * stuff MERGE_HEAD version in stage #3. */ ce_2 = read_one_ent("our", &head_oid, path, namelen, 2); ce_3 = read_one_ent("their", &merge_head_oid, path, namelen, 3); if (!ce_2 || !ce_3) { ret = -1; goto free_return; } if (!oidcmp(&ce_2->oid, &ce_3->oid) && ce_2->ce_mode == ce_3->ce_mode) { fprintf(stderr, "%s: identical in both, skipping.\n", path); goto free_return; } remove_file_from_cache(path); if (add_cache_entry(ce_2, ADD_CACHE_OK_TO_ADD)) { error("%s: cannot add our version to the index.", path); ret = -1; goto free_return; } if (!add_cache_entry(ce_3, ADD_CACHE_OK_TO_ADD)) return 0; error("%s: cannot add their version to the index.", path); ret = -1; free_return: cache_entry_free(ce_2); cache_entry_free(ce_3); return ret; }