vendor/libgit2/src/sortedcache.c in rugged-0.27.10.1 vs vendor/libgit2/src/sortedcache.c in rugged-0.28.0

- old
+ new

@@ -18,23 +18,23 @@ git_sortedcache *sc; size_t pathlen, alloclen; pathlen = path ? strlen(path) : 0; - GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen); - GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen); + GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); sc = git__calloc(1, alloclen); - GITERR_CHECK_ALLOC(sc); + GIT_ERROR_CHECK_ALLOC(sc); git_pool_init(&sc->pool, 1); if (git_vector_init(&sc->items, 4, item_cmp) < 0 || git_strmap_alloc(&sc->map) < 0) goto fail; if (git_rwlock_init(&sc->lock)) { - giterr_set(GITERR_OS, "failed to initialize lock"); + git_error_set(GIT_ERROR_OS, "failed to initialize lock"); goto fail; } sc->item_path_offset = item_path_offset; sc->free_item = free_item; @@ -165,11 +165,11 @@ int git_sortedcache_wlock(git_sortedcache *sc) { GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ if (git_rwlock_wrlock(&sc->lock) < 0) { - giterr_set(GITERR_OS, "unable to acquire write lock on cache"); + git_error_set(GIT_ERROR_OS, "unable to acquire write lock on cache"); return -1; } return 0; } @@ -184,11 +184,11 @@ int git_sortedcache_rlock(git_sortedcache *sc) { GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ if (git_rwlock_rdlock(&sc->lock) < 0) { - giterr_set(GITERR_OS, "unable to acquire read lock on cache"); + git_error_set(GIT_ERROR_OS, "unable to acquire read lock on cache"); return -1; } return 0; } @@ -217,18 +217,18 @@ error = fd; goto unlock; } if (p_fstat(fd, &st) < 0) { - giterr_set(GITERR_OS, "failed to stat file"); + git_error_set(GIT_ERROR_OS, "failed to stat file"); error = -1; (void)p_close(fd); goto unlock; } if (!git__is_sizet(st.st_size)) { - giterr_set(GITERR_INVALID, "unable to load file larger than size_t"); + git_error_set(GIT_ERROR_INVALID, "unable to load file larger than size_t"); error = -1; (void)p_close(fd); goto unlock; } @@ -268,12 +268,12 @@ } /* find and/or insert item, returning pointer to item data */ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key) { + size_t pos; int error = 0; - khiter_t pos; void *item; size_t keylen, itemlen; char *item_key; pos = git_strmap_lookup_index(sc->map, key); @@ -285,11 +285,11 @@ keylen = strlen(key); itemlen = sc->item_path_offset + keylen + 1; itemlen = (itemlen + 7) & ~7; if ((item = git_pool_mallocz(&sc->pool, (uint32_t)itemlen)) == NULL) { - /* don't use GITERR_CHECK_ALLOC b/c of lock */ + /* don't use GIT_ERROR_CHECK_ALLOC b/c of lock */ error = -1; goto done; } /* one strange thing is that even if the vector or hash table insert @@ -318,11 +318,11 @@ } /* lookup item by key */ void *git_sortedcache_lookup(const git_sortedcache *sc, const char *key) { - khiter_t pos = git_strmap_lookup_index(sc->map, key); + size_t pos = git_strmap_lookup_index(sc->map, key); if (git_strmap_valid_index(sc->map, pos)) return git_strmap_value_at(sc->map, pos); return NULL; } @@ -369,17 +369,17 @@ /* remove entry from cache */ int git_sortedcache_remove(git_sortedcache *sc, size_t pos) { char *item; - khiter_t mappos; + size_t mappos; /* because of pool allocation, this can't actually remove the item, * but we can remove it from the items vector and the hash table. */ if ((item = git_vector_get(&sc->items, pos)) == NULL) { - giterr_set(GITERR_INVALID, "removing item out of range"); + git_error_set(GIT_ERROR_INVALID, "removing item out of range"); return GIT_ENOTFOUND; } (void)git_vector_remove(&sc->items, pos);