diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2013-04-21 19:26:35 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-04-22 17:12:11 +0200 |
| commit | 05b179648aca91799274afbd03d40f31783547ac (patch) | |
| tree | 6eb7f09499286d115754c5c3e802053bbdcce0e6 /src/util.h | |
| parent | d08dd728a80eb993d80ec30d8c9f9025664c8990 (diff) | |
| download | libgit2-05b179648aca91799274afbd03d40f31783547ac.tar.gz | |
Make refcounting atomic
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util.h b/src/util.h index 82435aee8..687afe084 100644 --- a/src/util.h +++ b/src/util.h @@ -188,20 +188,20 @@ extern int git__strncmp(const char *a, const char *b, size_t sz); extern int git__strncasecmp(const char *a, const char *b, size_t sz); typedef struct { - short refcount; + git_atomic refcount; void *owner; } git_refcount; typedef void (*git_refcount_freeptr)(void *r); #define GIT_REFCOUNT_INC(r) { \ - ((git_refcount *)(r))->refcount++; \ + git_atomic_inc(&((git_refcount *)(r))->refcount); \ } #define GIT_REFCOUNT_DEC(_r, do_free) { \ git_refcount *r = (git_refcount *)(_r); \ - r->refcount--; \ - if (r->refcount <= 0 && r->owner == NULL) { do_free(_r); } \ + int val = git_atomic_dec(&r->refcount); \ + if (val <= 0 && r->owner == NULL) { do_free(_r); } \ } #define GIT_REFCOUNT_OWN(r, o) { \ |
