1
0
C_lib/utils/swap_void.c

15 lines
459 B
C
Raw Normal View History

/* Function to swap void* objects. */
#include <stdlib.h>
#include "swap_void.h"
/* This function swaps void* objects. */
/* Temp should be an allocated buffer, used to do the swap. */
/* Size should be > 0. */
/* Expect undefined behavior if conditions aren't met. */
extern inline void swap_void_ptr(void *first, void *second, void *temp, size_t size) {
/* Swap. */
memcpy(temp, first, size);
memcpy(first, second, size);
memcpy(second, temp, size);
}