Add a swap function that swaps contents of references.
This commit is contained in:
parent
df50579b5c
commit
85f88b909b
|
@ -83,6 +83,10 @@ void libab_ref_free(libab_ref* ref);
|
||||||
* Copies this reference, thereby increasing the reference count.
|
* Copies this reference, thereby increasing the reference count.
|
||||||
*/
|
*/
|
||||||
void libab_ref_copy(const libab_ref* ref, libab_ref* into);
|
void libab_ref_copy(const libab_ref* ref, libab_ref* into);
|
||||||
|
/**
|
||||||
|
* Swaps the contents of two references.
|
||||||
|
*/
|
||||||
|
void libab_ref_swap(libab_ref* left, libab_ref* right);
|
||||||
/**
|
/**
|
||||||
* Function that can be passed in to refcount to simply use free
|
* Function that can be passed in to refcount to simply use free
|
||||||
* when the refcount reaches 0.
|
* when the refcount reaches 0.
|
||||||
|
|
|
@ -57,6 +57,13 @@ void libab_ref_copy(const libab_ref* ref, libab_ref* into) {
|
||||||
memcpy(into, ref, sizeof(*ref));
|
memcpy(into, ref, sizeof(*ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void libab_ref_swap(libab_ref* left, libab_ref* right) {
|
||||||
|
libab_ref tmp;
|
||||||
|
tmp = *left;
|
||||||
|
*left = *right;
|
||||||
|
*right = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
void libab_ref_data_free(void* data) { free(data); }
|
void libab_ref_data_free(void* data) { free(data); }
|
||||||
|
|
||||||
void* libab_ref_get(const libab_ref* ref) {
|
void* libab_ref_get(const libab_ref* ref) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user