Indentation fix, cleanup.
[AROS.git] / compiler / stdc / memset.c
blobba38ccbecd24eff52eec47f0a24bdce54c0271af
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function memset().
6 */
8 #include <proto/exec.h>
10 /*****************************************************************************
12 NAME */
13 #include <string.h>
15 void * memset (
17 /* SYNOPSIS */
18 void * dest,
19 int c,
20 size_t count)
22 /* FUNCTION
23 Fill the memory at dest with count times c.
25 INPUTS
26 dest - The first byte of the destination area in memory
27 c - The byte to fill memory with
28 count - How many bytes to write
30 RESULT
31 dest.
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
40 memmove(), memcpy()
42 INTERNALS
44 ******************************************************************************/
46 UBYTE * ptr = dest;
48 while (((IPTR)ptr)&(AROS_LONGALIGN-1) && count)
50 *ptr ++ = c;
51 count --;
54 if (count > sizeof(ULONG))
56 ULONG * ulptr = (ULONG *)ptr;
57 ULONG fill;
59 fill = (ULONG)(c & 0xFF);
60 fill = (fill << 8) | fill;
61 fill = (fill << 16) | fill;
63 while (count > sizeof(ULONG))
65 *ulptr ++ = fill;
66 count -= sizeof(ULONG);
69 ptr = (UBYTE *)ulptr;
72 while (count --)
73 *ptr ++ = c;
75 return dest;
76 } /* memset */