summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/memory.c b/memory.c
index 8bca068..f1ff3a3 100644
--- a/memory.c
+++ b/memory.c
@@ -57,13 +57,13 @@ freearray(Array *a)
{
if(a == nil)
return;
- if(a->refs == 0){
+ if(GetRefs(a) == 0){
print("NEGATIVE REF COUNT (array)! %p\n", a);
threadexitsall(nil);
}
- a->refs--;
- if(a->refs == 0){
+ SetRefs(a, GetRefs(a)-1);
+ if(GetRefs(a) == 0){
if(GetType(a) == AtypeArray)
for(int i = 0; i < GetSize(a); i++)
freearray(a->arraydata[i]);
@@ -82,9 +82,9 @@ allocarray(arrayDataType t, int rank, int size)
SetType(a, t);
SetSize(a, size);
SetStrand(a, 0);
+ SetRefs(a, 1);
a->shape = emalloc(sizeof(*a->shape) * rank);
a->rawdata = emalloc(datasizes[t] * size);
- a->refs = 1;
arrayalloccounts++;
return a;
}
@@ -92,7 +92,7 @@ allocarray(arrayDataType t, int rank, int size)
void
incarrayref(Array *a)
{
- a->refs++;
+ SetRefs(a, GetRefs(a)+1);
}
Datum *