BRL-CAD
memset.c
Go to the documentation of this file.
1 /* M E M S E T . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @addtogroup libsysv */
21 /** @{ */
22 /** @file libsysv/memset.c
23  *
24  */
25 /** @} */
26 
27 #include "common.h"
28 
29 /* quell warnings */
30 #if defined(HAVE_WUNUSED_CONST_VARIABLE)
31 # if HAVE_GCC_DIAG_PRAGMAS
32 # pragma GCC diagnostic push /* begin ignoring warnings */
33 # pragma GCC diagnostic ignored "-Wunused-const-variable"
34 # elif HAVE_CLANG_DIAG_PRAGMAS
35 # pragma clang diagnostic push /* begin ignoring warnings */
36 # pragma clang diagnostic ignored "-Wunused-const-variable"
37 # endif
38 #endif
39 
40 /* quell empty-compilation unit warnings */
41 static const int unused = 0;
42 
43 #if defined(HAVE_WUNUSED_CONST_VARIABLE)
44 # if HAVE_GCC_DIAG_PRAGMAS
45 # pragma GCC diagnostic pop
46 # elif HAVE_CLANG_DIAG_PRAGMAS
47 # pragma clang diagnostic pop
48 # endif
49 #endif
50 
51 /*
52  * defined for the folks that don't seem to have a system memset()
53  */
54 #ifndef HAVE_MEMSET
55 #include "sysv.h"
56 
57 void *
58 memset(void *s, register int c, register size_t n)
59 {
60  register unsigned char *p=(char *)s;
61 
62  if (p) {
63  while (n-- > 0) {
64  *p++ = (unsigned char)c;
65  }
66  }
67 
68  return s;
69 }
70 
71 #endif
72 
73 /*
74  * Local Variables:
75  * mode: C
76  * tab-width: 8
77  * indent-tabs-mode: t
78  * c-file-style: "stroustrup"
79  * End:
80  * ex: shiftwidth=4 tabstop=8
81  */
if lu s
Definition: nmg_mod.c:3860
void * memset(void *s, register int c, register size_t n)
Definition: memset.c:58
Header file for the BRL-CAD common definitions.