Henri Verbeet a écrit :
On 17 February 2010 17:54, Christian Costa <titan.co...@wanadoo.fr> wrote:
+ if (TRACE_ON(d3d_shader))
+ {
+ int size = strlen(comment) + 1;
+ char* str = (char*)HeapAlloc(GetProcessHeap(), 0, size);
+ int i = 0;
+ char* line = str;
+ memcpy(str, comment, size);
+ DPRINTF("//");
+ while (i < size)
+ {
+ /* Find end of line */
+ while ((str[i] != 0) && (str[i] != 0x0a))
+ i++;
+ /* Terminate line and remove preceding 0x0d if any */
+ if (i && (str[i-1] == 0x0d))
+ str[i-1] = 0;
+ else
+ str[i] = 0;
+ /* Display line and prepare next line */
+ DPRINTF("%s\n", debugstr_an(line, strlen(line)));
+ i++;
+ line = str + i;
+ }
+ }
This code has several obvious issues.
Right. HeapFree call and HeapAlloc failure handling are missing. I could
also do something with the leading // in
the case of an empty string (if this could ever happen).
If there are other obvious issues I've forgotten. Please be more accurate.