Page 1 of 1

Memsetw

Posted: Sat Jan 04, 2003 9:15 pm
by jrfritz
Where can I get that function? A well tested one...in C? ( along with the other code it needs too )

Re:Memsetw

Posted: Sun Jan 05, 2003 12:39 am
by K.J.
Well... here's the beginning of it:

memsetw(void *dest, u_short w, u_long n);

Basically, just loop w number of times, writing the value in n to *dest(adding 2 each loop to *dest).

If you really, really need the actual code for the function, I can post it, but I think you ought to be able to code it with that info.

K.J.

Re:Memsetw

Posted: Sun Jan 05, 2003 4:04 am
by df
memsetw is just a wide version of memset. looks like a multibyte/unicode type version.

Re:Memsetw

Posted: Sun Jan 05, 2003 5:52 am
by Tim
The wide character version of memset would be wmemset(void *, wchar_t, size_t). But if sizeof(wchar_t)==sizeof(unsigned short) then it's the same thing.

Re:Memsetw

Posted: Sun Jan 05, 2003 10:43 am
by nullify
I think:

Code: Select all

void memsetw(void *s, int c, unsigned int n)
{
   __asm__ __volatile__
      ("cld\n\t"
      "rep\n\t"
      "stosw": : "c" (n), "a" (c), "D" (s));
}