1
0
Fork 0
C_lib/utils/swap_void.c

16 lines
396 B
C

/* Function to swap void* objects. */
#include "swap_void.h"
/* This function swaps void* objects. */
/* Size should be > 0. */
/* Expect undefined behavior if conditions aren't met. */
extern inline void swap_void_ptr(void *first, void *second, size_t size) {
/* Swap. */
char *a = (char*)first, *b = (char*)second, c;
while(size--) {
c = a[size];
a[size] = b[size];
b[size] = c;
}
}