Memsetw

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jrfritz

Memsetw

Post by jrfritz »

Where can I get that function? A well tested one...in C? ( along with the other code it needs too )
K.J.

Re:Memsetw

Post 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.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Memsetw

Post by df »

memsetw is just a wide version of memset. looks like a multibyte/unicode type version.
-- Stu --
Tim

Re:Memsetw

Post 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.
nullify

Re:Memsetw

Post 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));
}
Post Reply