Skip to content
This repository was archived by the owner on Jul 25, 2020. It is now read-only.

Revamp Cursor::get_{text,blob} functions #94

Merged
merged 2 commits into from
Jul 27, 2014

Conversation

lifthrasiir
Copy link
Collaborator

Along with usual lint suppressions, these commits change Cursor::get_{text,blob} to return an Option<&str> or Option<&[u8]>. This correctly handles NULL (hence fixes #92), and moreover, reduces the redundant allocations when the buffer doesn't need to be kept. This also makes Cursor::get_bytes fully redundant, so it has been removed.

they used to return a direct `String` or `Vec<u8>`, which may fail
when it should return `NULL`. other functions do not have this issue
since the automatic conversion is fully defined over INTEGER and
FLOAT internal types.

this commit changes them to return an optional `&str` or `&[u8]`.
this correctly handles `NULL`, and moreover, reduces the redundant
allocations when the buffer doesn't need to be kept. this also
makes `Cursor::get_bytes` fully redundant, so it has been removed.
kud1ing pushed a commit that referenced this pull request Jul 27, 2014
Revamp `Cursor::get_{text,blob}` functions
@kud1ing kud1ing merged commit 37d63f9 into linuxfood:master Jul 27, 2014
@kud1ing
Copy link
Contributor

kud1ing commented Jul 27, 2014

Awesome, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cursor::get_text() is not safe
2 participants