File: explicit_bzero.c

package info (click to toggle)
fetchmail 6.5.6-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,596 kB
  • sloc: ansic: 19,190; sh: 7,108; python: 2,395; perl: 564; yacc: 447; lex: 286; makefile: 260; awk: 124; lisp: 84; exp: 43; sed: 17
file content (31 lines) | stat: -rw-r--r-- 758 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stddef.h>
#include <string.h>
#include "config.h"

#ifndef HAVE_EXPLICIT_BZERO

#include "fetchmail.h"
#include <signal.h>

void explicit_bzero(void *buf, size_t sz)
{
    // try language standard implementations first
    // memset_explicit() is C23
    //
    // memset_s isn't widely available and not worth bothering
    //
    // actually the system feature test should have been covered
    // by fetchmail.h, and we should only be here as a fallback,
    // but just in case someone calls this legacy name directly...
# ifdef HAVE_MEMSET_EXPLICIT
    memset_explicit(buf, 0, sz);
# else
    // fallback implementation
    if (NULL == buf && 0 == sz) return;
    volatile char *p = buf;
    while(sz--) {
	*p++ = '\0';
    }
# endif
}
#endif