changed malloc in addlog function