Hi,
+ char * nstr1 = HeapAlloc(GetProcessHeap(), 0, count + 1); + char * nstr2 = HeapAlloc(GetProcessHeap(), 0, count + 1); + + memcpy(nstr1, str1, count + 1); strncoll is used to compare at most count characters (you can't access data after nullbyte). You're not null terminating nstr1 and nstr2 strings.
This function should be implemented without memory allocations.
Cheers, Piotr
Hi, Thank you very much for your answer!
strncoll is used to compare at most count characters (you can't access data after nullbyte). You're not null terminating nstr1 and nstr2 strings.
Yes, I forgott this. Thank you.
This function should be implemented without memory allocations.
Why? I don't think it is possible to implement it without any memory allocations.
On 11/15/10 14:53, Vitaly Perov wrote:
This function should be implemented without memory allocations.
Why? I don't think it is possible to implement it without any memory allocations.
I mean without copying the strings.
Using strcoll doesn't make much sense (here and in MSVCRT_strcoll implementation). If a broken/partial implementation is needed by an application using strncmp should be ok.
On Monday 15 November 2010 17:16:32 Piotr Caban wrote:
On 11/15/10 14:53, Vitaly Perov wrote:
This function should be implemented without memory allocations.
Why? I don't think it is possible to implement it without any memory allocations.
I mean without copying the strings.
Using strcoll doesn't make much sense (here and in MSVCRT_strcoll implementation). If a broken/partial implementation is needed by an application using strncmp should be ok.
Do you suggest implementing a stub, which just call linux strcoll()?
You are right, an application perfectly works with just stub.
But I think it is not too hard to implement strncoll comletely.
Could you look at my new patch in wine-patches, please?
On 11/17/10 15:14, Vitaly Perov wrote:
On Monday 15 November 2010 17:16:32 Piotr Caban wrote:
On 11/15/10 14:53, Vitaly Perov wrote:
This function should be implemented without memory allocations.
Why? I don't think it is possible to implement it without any memory allocations.
I mean without copying the strings.
Using strcoll doesn't make much sense (here and in MSVCRT_strcoll implementation). If a broken/partial implementation is needed by an application using strncmp should be ok.
Do you suggest implementing a stub, which just call linux strcoll()?
I think that we shouldn't use linux strcoll at all. It will not do what is needed. The default locale (on startup) of all c applications is "C", in this locale strcoll behaves exactly the same as strcmp.
If a partial implementation is needed by an application I would suggest something like this: int strncoll(char *str1, char *str2, int count) { /* FIXME: handle collates */ return strncmp(str1, str2, count); }
Cheers, Piotr