22 lines
359 B
C
22 lines
359 B
C
// assert
|
|
#include <assert.h>
|
|
// UINT_MAX
|
|
#include <stdint.h>
|
|
// free
|
|
#include <stdlib.h>
|
|
|
|
// struct meri_object
|
|
#include "meri_object.h"
|
|
|
|
void meri_retain(struct meri_object *p) {
|
|
assert(p->refcount < UINT_MAX);
|
|
p->refcount++;
|
|
}
|
|
|
|
void meri_release(struct meri_object *p) {
|
|
assert(p->refcount > 0);
|
|
p->refcount--;
|
|
if (p->refcount == 0) {
|
|
free(p);
|
|
}
|
|
}
|