Re: msi [2/2]: Use lstrlenW instead of sizeof to compute the length of local const unicode strings
20 Oct
2006
20 Oct
'06
1:32 p.m.
James Hawkins wrote:
static const WCHAR create_fmt[] = {'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`','%','s','`',' ','(',' ',0};
- size = sizeof(create_fmt) + lstrlenW(table) - 2; + size = lstrlenW(create_fmt) + lstrlenW(table) - 1;
Since the string is const, and we know it at compile time, using sizeof() is better as unlike lstrlenW() it has no runtime cost. How about doing something like? #define CONST_STRLENW(X) (sizeof (X)/ sizeof((X)[0]) - 1) size = CONST_STRLENW(create_fmt) + strlenW(table) - 1; Mike
7083
Age (days ago)
7083
Last active (days ago)
0 comments
1 participants
participants (1)
-
Mike McCormack