Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Memory.c - github.com/SoftEtherVPN/libhamcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c9a8a34d3340bcadd931752685a29bd239bb5056 (plain)
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
#include "Memory.h"

#include <string.h>

uint32_t Ham_Swap32(const uint32_t value)
{
	uint32_t swapped;
	((uint8_t *)&swapped)[0] = ((uint8_t *)&value)[3];
	((uint8_t *)&swapped)[1] = ((uint8_t *)&value)[2];
	((uint8_t *)&swapped)[2] = ((uint8_t *)&value)[1];
	((uint8_t *)&swapped)[3] = ((uint8_t *)&value)[0];
	return swapped;
}

void Ham_WriteAndSeek(void **dst, const void *src, const size_t size)
{
	if (!dst || !*dst)
	{
		return;
	}

	uint8_t **buf = (uint8_t **)dst;

	memcpy(*buf, src, size);
	*buf += size;
}