Juan Lang juan.lang@gmail.com writes:
+#ifdef WORDS_BIGENDIAN +/* Returns a byte-swapped copy of str, to be freed with HeapFree(). */ +static LPWSTR PropertyStorage_StringToLE(LPCWSTR str, size_t len) +{
- LPWSTR leStr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (leStr)
- {
memcpy(leStr, str, len * sizeof(WCHAR));
PropertyStorage_ByteSwapString(leStr, len);
- }
- return leStr;
+} +#else +#define PropertyStorage_StringToLE(s, l) (LPWSTR)(s) +#endif
You are still casting away const...
You are still casting away const...
Indeed I am, but now the warning is harmless: the const pointer is only read from, never written to. Making a const pointer in the little endian case would make the entire block rather messier, since having a non-const pointer is necessary in the big endian case: it's written to and freed.
If you'd rather I introduce #ifdefs in the block itself, let me know. --Juan
Juan Lang juan.lang@gmail.com writes:
You are still casting away const...
Indeed I am, but now the warning is harmless: the const pointer is only read from, never written to. Making a const pointer in the little endian case would make the entire block rather messier, since having a non-const pointer is necessary in the big endian case: it's written to and freed.
If you'd rather I introduce #ifdefs in the block itself, let me know.
No, but you can just wrap the whole thing in a function.