irungentoo/ProjectTox-Core — pull request #530 by vx-k (2013-08-25 22:25:16+00:00)
Title: Changing Lossless_UDP connections array so it will use tox_array (from misc_tools).

Currently, most of the Tox manually allocates and reallocates dynamic arrays. This method is prone to errors and duplicate code.

This series of commits will try to switch the code from manually-mananaged arrays to implementation found in testing/misc_tools.h. Currently, I am only working with connections array in Lossless_UDP.

Before merging, there's still quite a lot of things to do. I need to remove unused & commented-out code, and finish changing several functions.

It is also necessary to test the library to see if this changes introduced segfaults and/or wasted memory (currently this code compiles, but I haven't run it).

I also hope to get peer-review for the code, and see if people have any suggestions.

List of things left to do:
* finish changing `static int new_inconnection(Lossless_UDP *ludp, IP_Port ip_port)` and `static void free_connections(Lossless_UDP *ludp)` to the new list (currently they're commented out)
* remove commented out code
* peer-review tox_array code
* update wiki (http://wiki.tox.im/index.php/Internal_functions_and_data_structures#Linked_List)
* Add a function to add several variables at a time (all the data is stored in one memory location, so this would be pretty efficient).
* Possibly use tox_list for Lossless_UDP (also found in testing/misc_tools.h).

BTW: Currently the misc_tools code is located in testing directory. It should probably be moved to toxcore, and maybe separated into different files. There's also several other things that belong there. For example, I saw at least 10 copies of code like [this](https://github.com/vx-k/ProjectTox-Core/blob/master/testing/Lossless_UDP_testclient.c#L34) in different files.