@@ -22,13 +22,14 @@ namespace librapid::serialize {
22
22
23
23
DimType numDims = shape.ndim ();
24
24
size_t hashed = hasher ();
25
- memcpy (serialized.data (), &numDims, sizeof (DimType));
26
- memcpy (serialized.data () + sizeof (DimType),
27
- shape.data ().begin (),
28
- sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
29
- memcpy (serialized.data () + sizeof (DimType) + sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
30
- &hashed,
31
- sizeof (size_t ));
25
+ std::memcpy (serialized.data (), &numDims, sizeof (DimType));
26
+ std::memcpy (serialized.data () + sizeof (DimType),
27
+ shape.data ().begin (),
28
+ sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
29
+ std::memcpy (serialized.data () + sizeof (DimType) +
30
+ sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
31
+ &hashed,
32
+ sizeof (size_t ));
32
33
return serialized;
33
34
}
34
35
@@ -42,14 +43,14 @@ namespace librapid::serialize {
42
43
43
44
DimType numDims;
44
45
size_t hashed;
45
- memcpy (&numDims, data.data (), sizeof (DimType));
46
+ std:: memcpy (&numDims, data.data (), sizeof (DimType));
46
47
Shape shape = Shape::zeros (numDims);
47
- memcpy (shape.data ().begin (),
48
- data.data () + sizeof (DimType),
49
- sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
50
- memcpy (&hashed,
51
- data.data () + sizeof (DimType) + sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
52
- sizeof (size_t ));
48
+ std:: memcpy (shape.data ().begin (),
49
+ data.data () + sizeof (DimType),
50
+ sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS);
51
+ std:: memcpy (&hashed,
52
+ data.data () + sizeof (DimType) + sizeof (SizeType) * LIBRAPID_MAX_ARRAY_DIMS,
53
+ sizeof (size_t ));
53
54
54
55
LIBRAPID_ASSERT (
55
56
hashed == hasher (),
@@ -77,12 +78,12 @@ namespace librapid::serialize {
77
78
78
79
size_t elements = storage.size ();
79
80
size_t hashed = hasher ();
80
- memcpy (serialized.data (), &elements, sizeof (size_t ));
81
- memcpy (
81
+ std:: memcpy (serialized.data (), &elements, sizeof (size_t ));
82
+ std:: memcpy (
82
83
serialized.data () + sizeof (size_t ), storage.data (), sizeof (Scalar) * storage.size ());
83
- memcpy (serialized.data () + sizeof (size_t ) + sizeof (Scalar) * storage.size (),
84
- &hashed,
85
- sizeof (size_t ));
84
+ std:: memcpy (serialized.data () + sizeof (size_t ) + sizeof (Scalar) * storage.size (),
85
+ &hashed,
86
+ sizeof (size_t ));
86
87
return serialized;
87
88
}
88
89
@@ -94,12 +95,13 @@ namespace librapid::serialize {
94
95
95
96
size_t elements;
96
97
size_t hashed;
97
- memcpy (&elements, data.data (), sizeof (size_t ));
98
+ std:: memcpy (&elements, data.data (), sizeof (size_t ));
98
99
Storage<Scalar> storage (elements);
99
- memcpy (storage.data (), data.data () + sizeof (size_t ), sizeof (Scalar) * storage.size ());
100
- memcpy (&hashed,
101
- data.data () + sizeof (size_t ) + sizeof (Scalar) * storage.size (),
102
- sizeof (size_t ));
100
+ std::memcpy (
101
+ storage.data (), data.data () + sizeof (size_t ), sizeof (Scalar) * storage.size ());
102
+ std::memcpy (&hashed,
103
+ data.data () + sizeof (size_t ) + sizeof (Scalar) * storage.size (),
104
+ sizeof (size_t ));
103
105
104
106
LIBRAPID_ASSERT (
105
107
hashed == hasher (),
@@ -148,12 +150,12 @@ namespace librapid::serialize {
148
150
std::vector<uint8_t > serialized;
149
151
serialized.resize (shapeBytes + storageBytes);
150
152
151
- memcpy (
153
+ std:: memcpy (
152
154
serialized.data (), SerializerImpl<ShapeType>::serialize (shape).data (), shapeBytes);
153
- memcpy (serialized.data () + shapeBytes,
154
- SerializerImpl<StorageType>::serialize (storage).data (),
155
- storageBytes);
156
- memcpy (serialized.data () + shapeBytes + storageBytes, &hashed, sizeof (size_t ));
155
+ std:: memcpy (serialized.data () + shapeBytes,
156
+ SerializerImpl<StorageType>::serialize (storage).data (),
157
+ storageBytes);
158
+ std:: memcpy (serialized.data () + shapeBytes + storageBytes, &hashed, sizeof (size_t ));
157
159
158
160
return serialized;
159
161
}
@@ -170,8 +172,8 @@ namespace librapid::serialize {
170
172
data.begin () + SerializerImpl<ShapeType>::serialize (shape).size (), data.end ()));
171
173
172
174
Type ret;
173
- ret.size_ () = shape.size ();
174
- ret.shape () = shape;
175
+ ret.size_ () = shape.size ();
176
+ ret.shape () = shape;
175
177
ret.storage () = storage;
176
178
return ret;
177
179
}
0 commit comments