diff options
author | Jakob Odersky <jakob@inpher.io> | 2019-10-09 17:10:43 -0400 |
---|---|---|
committer | Jakob Odersky <jakob@inpher.io> | 2019-10-09 20:33:16 -0400 |
commit | 0ceee5ed4bae240b8c8e94d2fd7424d9d0b67ec7 (patch) | |
tree | 2df0258f81050e6fed51d38e217c4f6256518e12 /client/src/http/ArrayUtils.scala | |
parent | faed28c54900fc0b359700873367095f51425794 (diff) | |
download | scala-triad-0ceee5ed4bae240b8c8e94d2fd7424d9d0b67ec7.tar.gz scala-triad-0ceee5ed4bae240b8c8e94d2fd7424d9d0b67ec7.tar.bz2 scala-triad-0ceee5ed4bae240b8c8e94d2fd7424d9d0b67ec7.zip |
Migrate build to mill
Diffstat (limited to 'client/src/http/ArrayUtils.scala')
-rw-r--r-- | client/src/http/ArrayUtils.scala | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/client/src/http/ArrayUtils.scala b/client/src/http/ArrayUtils.scala new file mode 100644 index 0000000..00c1067 --- /dev/null +++ b/client/src/http/ArrayUtils.scala @@ -0,0 +1,28 @@ +package triad +package http + +import scala.scalanative.native._ + +object ArrayUtils { + + def toBuffer(array: Array[Byte])(implicit z: Zone): Ptr[Byte] = { + val buffer = z.alloc(array.size) + var i = 0 + while (i < array.size) { + buffer(i) = array(i) + i += 1 + } + buffer + } + + def toArray(buffer: Ptr[Byte], size: CSize): Array[Byte] = { + val array = new Array[Byte](size.toInt) + var i = 0 + while (i < array.size) { + array(i) = buffer(i) + i += 1 + } + array + } + +} |