CleverRaven/Cataclysm-DDA — pull request #9491 by BevapDin (2014-10-09 21:55:44+00:00)
Title: Fix a memory leak

Valgrind says:

```
==24907== 176 (72 direct, 104 indirect) bytes in 2 blocks are definitely lost in loss record 539 of 579
==24907== at 0x4028892: operator new(unsigned int) (vg_replace_malloc.c:292)
==24907== by 0x8223162: mapf::basic_bind(std::string, ...) (mapgenformat.cpp:154)
==24907== by 0x83F1FFD: mapgen_road_curved(map*, oter_id, mapgendata, int, float) (mapgen_functions.cpp:1175)
==24907== by 0x832546A: mapgen_function_builtin::generate(map*, oter_id, mapgendata, int, float) (mapgen.h:35)
==24907== by 0x8293E11: map::draw_map(oter_id, oter_id, oter_id, oter_id, oter_id, oter_id, oter_id, oter_id, oter_id, oter
==24907== by 0x8289B1D: map::generate(int, int, int, int) (mapgen.cpp:92)
==24907== by 0x84F735D: map::loadn(int, int, int, int, int, bool) (map.cpp:4761)
==24907== by 0x84F55B9: map::load_abs(int, int, int, bool) (map.cpp:4439)
==24907== by 0x84F5655: map::load(int, int, int, bool, overmap*) (map.cpp:4448)
==24907== by 0x851ADFB: game::start_game(std::string) (game.cpp:615)
==24907== by 0x822AA0F: game::opening_screen() (main_menu.cpp:419)
==24907== by 0x85D4515: main (main.cpp:286)
```
As `map::generate` is called several times, it's likely that this leak happens often during game play.

Mapgen is often done like this:
```
mapf::formatted_set_simple(a_map, 0, 0,
" |------|-|-|ww---| ( the map as ASCII )",
mapf::basic_bind("u A F", t_floor, t_elevator, t_stairs_down),
mapf::basic_bind("u A F", f_cupboard, f_armchair, f_sofa));
```
`basic_bind` creates something and returns a raw pointer (`return new internal::format_effect(...)`). That pointer is given to `formatted_set_simple`, but `formatted_set_simple` does never free it!

This is solved by making all the raw pointers into `std::shared_ptr`. They delete themself.

I removed `formatted_set_terrain` because the varg style parameters do not work with objects (like `shared_ptr`) and `formatted_set_simple` is better formatted.