[RFC] cmd: Add a space at the end of the first echo'ed batch line [try5]

Vitaliy Margolen wine-devel at kievinfo.com
Mon Nov 1 09:12:47 CDT 2010


On 11/01/2010 07:37 AM, GOUJON Alexandre wrote:
> Hi everyone,
>
> I'm trying to fix the wine cmd behavior but as this 5th try differs greatly
> with the previous one, I'd like to have some feedback before submitting it.
>
> If you have any question, just let me know.
> Thanks is advance.
>

> +    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.
You should move declaration from compare_line() and use it instead here.

> +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.

> +    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.

> +        new_size += b-a +1;
You are modifying the new_size pointer instead of value it points to.


> +    if(!run_cmd(actual_cmd_data, actual_cmd_size))
>          return;
You leaking actual_cmd_data here.

> +    if(actual_cmd_data)
> +        free(actual_cmd_data);
Don't need to check if pointer is NULL before freeing it. free() and 
HeapFree() do that already.

Vitaliy.



More information about the wine-devel mailing list