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

Function mon_animal_list

src/mon.c:4828–4852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4826}
4827
4828void
4829mon_animal_list(boolean construct)
4830{
4831 if (construct) {
4832 short animal_temp[SPECIAL_PM];
4833 int i, n;
4834
4835 /* if (animal_list) impossible("animal_list already exists"); */
4836
4837 for (n = 0, i = LOW_PM; i < SPECIAL_PM; i++)
4838 if (is_animal(&mons[i]))
4839 animal_temp[n++] = i;
4840 /* if (n == 0) animal_temp[n++] = NON_PM; */
4841
4842 ga.animal_list = (short *) alloc(n * sizeof *ga.animal_list);
4843 (void) memcpy((genericptr_t) ga.animal_list,
4844 (genericptr_t) animal_temp,
4845 n * sizeof *ga.animal_list);
4846 ga.animal_list_count = n;
4847 } else { /* release */
4848 if (ga.animal_list)
4849 free((genericptr_t) ga.animal_list), ga.animal_list = 0;
4850 ga.animal_list_count = 0;
4851 }
4852}
4853
4854staticfn int
4855pick_animal(void)

Callers 1

pick_animalFunction · 0.85

Calls 1

allocFunction · 0.70

Tested by

no test coverage detected