Use memcpy and tor_malloc_zero to avoid some loops
Simplify some opening and closing brackets
Use const char pointers