From: Alexandre Julliard Subject: Re: [PATCH] include: Add and use a global heap_strdupW() helper Message-Id: <87o9kuo6ac.fsf@winehq.org> Date: Mon, 12 Feb 2018 11:23:39 +0100 In-Reply-To: <20180209204421.12241-1-mstefani@winehq.org> (Michael Stefaniuc's message of "Fri, 9 Feb 2018 21:44:21 +0100") References: <20180209204421.12241-1-mstefani@winehq.org> Michael Stefaniuc writes: > +static inline WCHAR *heap_strdupW(const WCHAR *str) > +{ > + WCHAR *dst; > + SIZE_T len; > + > + if(!str) > + return NULL; > + > + len = (lstrlenW(str) + 1) * sizeof(*str); > + dst = heap_alloc(len); > + if (dst) > + memcpy(dst, str, len); > + > + return dst; > +} I'm not sure the NULL check is a good idea. (just when you thought this one would not be controversial ;-) -- Alexandre Julliard julliard@winehq.org