[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: Re: advpack: Implement LaunchINFSectionEx [resend]
From: Alexandre Julliard <julliard () winehq ! org>
Date: 2006-03-31 9:32:11
Message-ID: 874q1f0xk4.fsf () wine ! dyndns ! org
[Download RAW message or body]
"James Hawkins" <truiken@gmail.com> writes:
> +static LPWSTR get_parameter(LPWSTR parameters, WCHAR separator, DWORD index)
> +{
> + LPWSTR param = NULL, ptr = parameters;
> + DWORD i = 0;
> +
> + while (*parameters && i < index)
> + {
> + if (*parameters == separator)
> + {
> + ptr = parameters;
> + i++;
> + }
> +
> + parameters++;
> + }
> +
> + if (!*parameters || *parameters == separator)
> + return NULL;
> +
> + param = HeapAlloc(GetProcessHeap(), 0, (parameters - ptr) * sizeof(WCHAR));
> + lstrcpynW(param, parameters, parameters - ptr);
> +
> + return param;
> +}
That's a very inefficient way of splitting a string. It's much better
to allocate a copy of the whole string and go through it just once,
inserting nulls to separate the tokens.
--
Alexandre Julliard
julliard@winehq.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic