-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 2014-10-12 19:47, schrieb Jonathan Vollebregt:
I don't free the old string. Because the function handles more than one type of data the caller has to free the data when it's done - if I don't copy the string it will end up freeing one of it's own parameters. I used bad terminology here. What I meant was that wchar_get_data could operate on the input memory instead of copying it first since the original data is not needed after the call.
Of course further features may require that the input remains untouched. Is this the case? There's another ugliness though: If the input string is "0", replacing it with a 4-byte DWORD just works because it is a WCHAR that consists of two two bytes elements. I don't know about other data types - they may actually grow.
Sorry, this seems confusing without comments. The REG_MULTI_SZ stores multiple strings in the registry: nil separated with a double nil to end the array.
When reading from the registry simply replacing the nil's with ',' seems the simplest way to do it, and that's exactly wine's regedit's behaviour. I'm not sure what the native behaviour is supposed to be though. As I mentioned tests would be a good idea :-) .
I understood what the function was doing after enough reading. What I meant was that there was probably a nicer way to implement the same behavior. E.g. if you do the character replace in the existing string you could write this as for (i = 0; inout[i] || input[i + 1]; i++) { if (!inout[i]) inout[i] = ','; } Or MakeMULTISZDisplayable() from regedit. MakeMULTISZDisplayable is probably faster because it does only one comparison per character. But if you cannot operate on the input data that idea is moot. You could copy first and then run a second iteratation over the string, but I think that results in worse performance than your code.
If the separator has been left out of the commandline, the separator variable here will be 0. By default reg (From everything I've read) interprets "\\0" as the separator - that is it takes an escaped nil as it's input to split the strings.
If you *do* supply a separator variable though it will split by that, so the following commands should have an equivalent effect:
reg add HKCU /v test /t REG_MULTI_SZ /d "string\\0morestring" reg add HKCU /v test /t REG_MULTI_SZ /s "#" /d "string#morestring" You mean it uses a two-byte separator '\\','0', rather than the one-byte separator '\0'? In this case it would be best to make the code work on generic string separators. The default separator needs tests as well.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIbBAEBAgAGBQJUOs42AAoJEN0/YqbEcdMw7LwP9RJ8PddCWJpZqRATzimyWe3X pQDhtf3rE696zA3w4lMXom++V5YJDFkJp3wmX7EMyH2+EKROFBVkhPV9C2dk+eFc m8Wfrq5+HSOc7nb2uB6c7AqZMVHLbooSFIHsiX0lmmDDdPI1I60EUhdk243i6PeR c4ItRWbqDAj2Fa/4b4dZ7K3O1OyBDpT0fChmFJabtFMFQPoOxZhgv8SJbMC0Uv0K 0HVN8vsizLkMycAYk7cf4P914b+u9uPSDWsllvfMmgh+ABo2pDd6b57N8abVABoC y6fDLasFuPBbAxeJKjVbMvKRvuNAvkEHj4XmvxPoaniFBamsC7Mr13T9mPiyhXDR yhbHbI5w3AZdCPRjbe2B25jtwthNriVQ/C+D9GGENvuw0qxj0WiAsPB9xllMSYYZ E9OaDPEpcV0NmyCdDyV3jIiMupZ8uk2wqaHHCkWkJx2r4/V3iDYuAuOhQVZsjrei JAuAShe3ZTkvoGTNDhL43eMq7Wxp5LhMIa03JQVuQCGFZgfrd3TotlAHVtfGYpSc oMuxN8Uv2vx7s9eg32yvovWsjoJDcUlXaQkZVtS4j0ZXXM1Cu8LcBglzbJj8303+ XLBO2fxs3gV3THziOemCLD+IYyKuXOoqTEgpmPUuT5NSoPeFywJKiuOlqcMwikrW P80DHs/eIFBWbJcLRLo= =AGZl -----END PGP SIGNATURE-----