On 11/01/2010 03:12 PM, Vitaliy Margolen wrote:
- static const char escaped_space[] = "@space@";
- DWORD len_space = strlen(escaped_space);
The better way to calculate size of a static string, which is a compile time calculation. strlen() call is a runtime.
The better way is ... ? In compare_line(), sizeof(space_cmd) is used but I guess sizeof(space_cmd/space_cmd[0]) is more portable, isn't it ? I thought strlen() was optimized in that case because used with a const string.
+static char* replace_escaped_spaces(const char *data, DWORD size, DWORD *new_size)
- char *a, *b, *new_data;
- a = b = (char*)data;
a, b should be "const char*" as well.
Unfortunately, I can't do that : strncpy and HeapFree complains about const strings.
- new_data = (char*)malloc(size*sizeof(char));
Don't use malloc in Wine. Use HeapAlloc & co. This is not c++, don't need to typecast (void*) pointer.
Got it. I'll remember this for next times.
I modified my patch according to your suggestions. I also changed the way I update new_data to simply return it (more understandable, I think). Can you review it again, please ?
Vitaliy.
Many thanks, I'm avoiding try[6-9] with your advices !!