| 441 | } |
| 442 | |
| 443 | static cbm_graph_mem_t *gm_new_entry(const char *db_path, const char *version, size_t est) { |
| 444 | cbm_graph_mem_t *g = cbm_calloc(CBM_MEM_CLASS_GRAPH_CACHE, sizeof(*g)); |
| 445 | if (!g) { |
| 446 | return NULL; |
| 447 | } |
| 448 | g->path = cbm_mem_strdup(CBM_MEM_CLASS_GRAPH_CACHE, db_path); |
| 449 | if (!g->path) { |
| 450 | gm_free_ptr(g); |
| 451 | return NULL; |
| 452 | } |
| 453 | memcpy(g->version, version, strlen(version) + 1); |
| 454 | g->refs = 1; |
| 455 | g->bytes = est; |
| 456 | return g; |
| 457 | } |
| 458 | |
| 459 | cbm_graph_mem_t *cbm_graph_mem_acquire(sqlite3 *db, const char *db_path, const char *version) { |
| 460 | if (!db || !db_path || !version || !version[0] || strlen(version) >= GM_VERSION_MAX) { |
no test coverage detected