the call to new_affect() allocates memory.
Code:
/* Every spell that does an affect comes through here. This determines the
* effect, whether it is added or replacement, whether it is legal or not, etc.
* affect_join(vict, aff, add_dur, avg_dur, add_mod, avg_mod) */
#define MAX_SPELL_AFFECTS 5 /* change if more needed */
void mag_affects(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype)
{
struct affected_type af[MAX_SPELL_AFFECTS];
bool accum_affect = FALSE, accum_duration = FALSE;
const char *to_vict = NULL, *to_room = NULL;
int i, j;
if (victim == NULL || ch == NULL)
return;
if (spellnum == SPELL_TREE_TRAVEL) {
struct obj_data *tree;
for (tree = world[ch->in_room].contents; tree; tree = tree->next_content)
if (GET_OBJ_TYPE(tree) == ITEM_TREE)
break;
if (tree == NULL) {
send_to_char(ch, "But there is no tree around to travel from.\r\n");
return;
}
}
for (i = 0; i < MAX_SPELL_AFFECTS; i++) {
new_affect(&(af[i]));
af[i].spell = spellnum;
}
switch (spellnum) {
case SPELL_TREE_TRAVEL:
af[0].duration = 24;
SET_BIT_AR(af[0].bitvector, AFF_TREE_TRAVEL);
accum_duration = FALSE;
to_vict = "You feel one with the trees!";
break;
} /* end of cases */