summaryrefslogtreecommitdiffstats
path: root/src/lib/safe-memset.c
blob: 3062a419723f8d19abdfddec7b999371627f203d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "safe-memset.h"

void safe_memset(void *data, int c, size_t size)
{
	volatile unsigned int volatile_zero_idx = 0;
	volatile unsigned char *p = data;

	if (size == 0)
		return;

	do {
		memset(data, c, size);
	} while (p[volatile_zero_idx] != c);
}