--- a/FloatArray.st Fri Sep 15 14:31:21 2017 +0200
+++ b/FloatArray.st Fri Sep 15 15:25:57 2017 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
@@ -54,8 +56,6 @@
"
! !
-
-
!FloatArray class methodsFor:'queries'!
elementByteSize
@@ -67,7 +67,6 @@
"Created: / 15-09-2011 / 14:12:39 / cg"
! !
-
!FloatArray methodsFor:'copying'!
clone
@@ -119,16 +118,29 @@
// don't do this; sizeof returns the padded size!
// nBytes = sizeof(struct __FloatArray) + (__n - 1) * sizeof(float);
- nBytes = OHDR_SIZE + (__n * sizeof(float));
+ /* and what is the disadvantage of having the padded size?
+ in an 32 bit enviroments, we do need the padded size,
+ otherwise there are to less bytes allocated */
+ // nBytes = OHDR_SIZE + (__n * sizeof(float));
+ nBytes = sizeof(struct __FloatArray) + (__n - 1) * sizeof(float);
// printf("__n=%d nBytes=%d\n", __n, nBytes);
__nObj = __STX___new(nBytes);
+
if (__nObj != nil) {
__objPtr(__nObj)->o_class = __qClass(self);
__STORE(__nObj, __qClass(self));
- bcopy(__FloatArrayInstPtr(self)->f_element + __start,
- __FloatArrayInstPtr(__nObj)->f_element,
- sizeof(float) * __n);
+ // bcopy is marked as deprecated
+ // bcopy(
+ // __FloatArrayInstPtr(self)->f_element,
+ // __FloatArrayInstPtr(__nObj)->f_element + __start,
+ // __n * sizeof(float));
+
+ memcpy(
+ __FloatArrayInstPtr(__nObj)->f_element + __start,
+ __FloatArrayInstPtr(self)->f_element,
+ __n * sizeof(float));
+
RETURN(__nObj);
}
}
@@ -142,8 +154,8 @@
|f1 f2|
f1 := FloatArray withAll:#(1 2 3 4 5 6).
- f2 := f1 copyFrom:2 to:4.
- f2
+ f2 := f1 copyFrom:1 to:3.
+ f2
"
!
@@ -944,7 +956,6 @@
"
! !
-
!FloatArray class methodsFor:'documentation'!
version