MCPcopy Create free account
hub / github.com/NetHack/NetHack / add_id_mapping

Function add_id_mapping

src/restore.c:1459–1476  ·  view source on GitHub ↗

Add a mapping to the ID map. */

Source from the content-addressed store, hash-verified

1457
1458/* Add a mapping to the ID map. */
1459staticfn void
1460add_id_mapping(unsigned int gid, unsigned int nid)
1461{
1462 int idx;
1463
1464 idx = gn.n_ids_mapped % N_PER_BUCKET;
1465 /* idx is zero on first time through, as well as when a new bucket is */
1466 /* needed */
1467 if (idx == 0) {
1468 struct bucket *gnu = (struct bucket *) alloc(sizeof(struct bucket));
1469 gnu->next = gi.id_map;
1470 gi.id_map = gnu;
1471 }
1472
1473 gi.id_map->map[idx].gid = gid;
1474 gi.id_map->map[idx].nid = nid;
1475 gn.n_ids_mapped++;
1476}
1477
1478/*
1479 * Global routine to look up a mapping. If found, return TRUE and fill

Callers 2

restobjchnFunction · 0.85
restmonchnFunction · 0.85

Calls 1

allocFunction · 0.70

Tested by

no test coverage detected