rainwoodman / vast

vala and scientific numerical computation
11 stars 1 forks source link

Handle string in get_pointer and set_pointer #36

Closed arteymix closed 7 years ago

arteymix commented 7 years ago

I wonder whether we should do this there because actually, if you use the pointer API with string, you have to allocate scalar_size.

arteymix commented 7 years ago

Basically, it would be about using strncpy instead of memcpy.

rainwoodman commented 7 years ago

What about a special function, eg. set_from_string that crashes if the array is not a string.

s.t.

set_pointer expects fixed-length string, and
set_from_string expects null-terminated string.

The name set_pointer is horrible by the way, we don't set any pointer but we copy the data from the pointer into the internal buffer. 'copy_pointer'? 'dup_pointer'?, 'set_from_pointer'?

arteymix commented 7 years ago

I agree and set_from_pointer sounds best to me. We should rename set_value as well since we copy it's internal data field.

arteymix commented 7 years ago

Maybe a set_from_string would a nice-to-have as well with get_string.

arteymix commented 7 years ago

We can also handle null-terminated type in general, though I don't see much interest beyond strings.