#How to convert *error{OutOfMemory}![]u8 to *[]u8

1 messages · Page 1 of 1 (latest)

potent widget
#

title

#

How to convert *error{OutOfMemory}![]u8 to *[]u8

#

seems impossible tbf

#

Trying to pass an allocated var into a function

formal matrix
#

how did you get a *error{OutOfMemory}![]u8 in the first place? - this is quite an odd type

potent widget
#

But it says I can't index errorOutofMemory

finite valve
#

try allocator.alloc

potent widget
#

oh

#

mb

#

thanks

formal matrix
#

also, should output be a *[]u8? - that's a double pointer...

potent widget
#

Hmmmm

#

not sure

formal matrix
#

it might be that you need only accept a []u8

potent widget
#

Ok

potent widget
#

Oh

#

[]u8 is different from []const u8

finite valve
#

do you want to change the bytes stored in the location it points to? or do you want to make it point to a different location?

potent widget
finite valve
#

then *[]u8 or *[]const u8 is correct

potent widget
#

kk thx

potent widget
finite valve
#

the first one lets you write to the u8s it points to, the second one doesn't

potent widget
finite valve
#

oh then you probably just want []u8