commit e82a0b1f50c85b262a2f397a410dd6d9b2360cfb
parent 9cbcbd6f9384e42a6268f0ebb3686db3d4cf5d2c
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Fri, 1 Apr 2022 20:23:13 +0000
array: add arrayset (not used anywhere)
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/array.c b/array.c
@@ -167,3 +167,16 @@ arrayinsert(Array *ap, long n, long m, void *v)
qunlock(ap->l);
return vs;
}
+
+void *
+arrayset(Array *ap, long n, void *v)
+{
+ assert(ap->magic == MAGIC);
+ if (_arraycheck(ap, n, "arrayset") != 0) return nil;
+ qlock(ap->l);
+ if (v != nil) {
+ memcpy(ap->p + ap->size * n, v, ap->size);
+ }
+ qunlock(ap->l);
+ return _arrayget(ap, n);
+}
+\ No newline at end of file
diff --git a/array.h b/array.h
@@ -17,3 +17,4 @@ void * arraygrow(Array *, long, void *);
void * arrayget(Array *, long, void *);
void * arrayend(Array *);
void * arrayinsert(Array *, long, long, void *);
+void * arrayset(Array *, long, void *);