Gokul
Gokul
MModular
Created by Gokul on 12/7/2023 in #questions
How does memcpy work in 0.6.0 ?
Before, I wrote a helper function for string vector in 0.5.0 and memcpy was working fine, now I am unable to do so in 0.6.0, this is code snippet:
alias strtype = DTypePointer[DType.int8]
var data: Pointer[strtype]
...
self.data = self.data.alloc(self.capacity)

# previously this worked in 0.5.0
let str_data = strtype.alloc(len(str)+1)
memcpy(str_data, str._buffer.data, len(str)+1)

# In version 0.6.0 this statement fails:
memcpy(str_data, str._buffer.data, len(str)+1)

# so i tried this, but this also fails
alias strtype = DTypePointer[DType.int8, 0]
...
memcpy[DType.int8, 0](str_data, str._buffer.data, len(str)+1)
error i got was: candidate not viable: callee parameter #0 has 'AnyRegType' type, but value has type 'DType'
alias strtype = DTypePointer[DType.int8]
var data: Pointer[strtype]
...
self.data = self.data.alloc(self.capacity)

# previously this worked in 0.5.0
let str_data = strtype.alloc(len(str)+1)
memcpy(str_data, str._buffer.data, len(str)+1)

# In version 0.6.0 this statement fails:
memcpy(str_data, str._buffer.data, len(str)+1)

# so i tried this, but this also fails
alias strtype = DTypePointer[DType.int8, 0]
...
memcpy[DType.int8, 0](str_data, str._buffer.data, len(str)+1)
error i got was: candidate not viable: callee parameter #0 has 'AnyRegType' type, but value has type 'DType'
I have noticed, that a concept of address space is introduced, but I am not able to find solid examples to learn from. Need some help
9 replies