On Thu, 16.08.12 10:23, Shawn Landden ([email protected]) wrote: > config_parse_join_controllers() not converted cause that is a const > char *
Umm, so I am not really a fan of changing strings and then back. I mean, sure in this case this would work. But there are so many other cases where it doesn't, that I don't even want to start with this style here. If people see this in the sources, they might blindly think that this is OK everywhere else, too, but it isn't. For example, if this was argv[] we are talking of then patching it would be immediately visible outside of the process in "ps". This would also break in threaded situations. And it would also break if the string passed is const and in a RO section in the binary. This is usually not an inner loop that is executed more than a few times, so maybe this is not the place to optimize anyway? That said, an acceptable solution would be to allocate this dynamically on the stack. Since this is executed in a loop alloca() would not work, but C99 variable size arrays would. This would get rid of the heap allocation, and replace it with a cheap stack allocation, but would still require copying memory. Lennart -- Lennart Poettering - Red Hat, Inc. _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
