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: 237efb9d11399f298315b23e90b211a4026505ff (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
27
28
#include "Memory.h"

#include <string.h>

size_t CompressionBufferSize(const size_t original_size) { return original_size * 2 + 256; }

uint32_t 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 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;
}