Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
99 lines
2.5 KiB
C
99 lines
2.5 KiB
C
#ifndef OIDMAP_H
|
|
#define OIDMAP_H
|
|
|
|
#include "hash.h"
|
|
#include "hashmap.h"
|
|
|
|
/*
|
|
* struct oidmap_entry is a structure representing an entry in the hash table,
|
|
* which must be used as first member of user data structures.
|
|
*
|
|
* Users should set the oid field. oidmap_put() will populate the
|
|
* internal_entry field.
|
|
*/
|
|
struct oidmap_entry {
|
|
/* For internal use only */
|
|
struct hashmap_entry internal_entry;
|
|
|
|
struct object_id oid;
|
|
};
|
|
|
|
struct oidmap {
|
|
struct hashmap map;
|
|
};
|
|
|
|
#define OIDMAP_INIT { { NULL } }
|
|
|
|
/*
|
|
* Initializes an oidmap structure.
|
|
*
|
|
* `map` is the oidmap to initialize.
|
|
*
|
|
* If the total number of entries is known in advance, the `initial_size`
|
|
* parameter may be used to preallocate a sufficiently large table and thus
|
|
* prevent expensive resizing. If 0, the table is dynamically resized.
|
|
*/
|
|
void oidmap_init(struct oidmap *map, size_t initial_size);
|
|
|
|
/*
|
|
* Clear an oidmap, freeing any allocated memory. The map is empty and
|
|
* can be reused without another explicit init.
|
|
*
|
|
* If `free_entries` is true, each oidmap_entry in the map is freed as well
|
|
* using stdlibs free().
|
|
*/
|
|
void oidmap_clear(struct oidmap *map, int free_entries);
|
|
|
|
/*
|
|
* Returns the oidmap entry for the specified oid, or NULL if not found.
|
|
*/
|
|
void *oidmap_get(const struct oidmap *map,
|
|
const struct object_id *key);
|
|
|
|
/*
|
|
* Adds or replaces an oidmap entry.
|
|
*
|
|
* ((struct oidmap_entry *) entry)->internal_entry will be populated by this
|
|
* function.
|
|
*
|
|
* Returns the replaced entry, or NULL if not found (i.e. the entry was added).
|
|
*/
|
|
void *oidmap_put(struct oidmap *map, void *entry);
|
|
|
|
/*
|
|
* Removes an oidmap entry matching the specified oid.
|
|
*
|
|
* Returns the removed entry, or NULL if not found.
|
|
*/
|
|
void *oidmap_remove(struct oidmap *map, const struct object_id *key);
|
|
|
|
static inline unsigned int oidmap_get_size(struct oidmap *map)
|
|
{
|
|
return hashmap_get_size(&map->map);
|
|
}
|
|
|
|
struct oidmap_iter {
|
|
struct hashmap_iter h_iter;
|
|
};
|
|
|
|
static inline void oidmap_iter_init(struct oidmap *map, struct oidmap_iter *iter)
|
|
{
|
|
hashmap_iter_init(&map->map, &iter->h_iter);
|
|
}
|
|
|
|
static inline void *oidmap_iter_next(struct oidmap_iter *iter)
|
|
{
|
|
/* TODO: this API could be reworked to do compile-time type checks */
|
|
return (void *)hashmap_iter_next(&iter->h_iter);
|
|
}
|
|
|
|
static inline void *oidmap_iter_first(struct oidmap *map,
|
|
struct oidmap_iter *iter)
|
|
{
|
|
oidmap_iter_init(map, iter);
|
|
/* TODO: this API could be reworked to do compile-time type checks */
|
|
return (void *)oidmap_iter_next(iter);
|
|
}
|
|
|
|
#endif
|