Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Cleanup slices, strings, tags, and vecs#44

Merged
morrisonlevi merged 7 commits into
mainfrom
levi/cleanup
Apr 12, 2022
Merged

Cleanup slices, strings, tags, and vecs#44
morrisonlevi merged 7 commits into
mainfrom
levi/cleanup

Conversation

@morrisonlevi

Copy link
Copy Markdown
Collaborator

This started with enhancing tags, but when I was done I discovered a
sigsev which could be triggered even from Rust code. I knew I had
screwed up the lifetimes and unsafe code.

So, I started working and I kept unravelling more and more.

Slice and vec have been split into their own files as lib.rs was
getting large.

Many From traits were changed to work with &T instead of T because of
lifetime issues.

In this PR, some C FFI APIs for tags have been removed. A subsequent PR
will add them back and enhance them. I wanted to keep the PR size to be
somewhat manageable.

Some places using some form of string have changed to use
Cow<'static, str>. This allows you to borrow static strings, and own
all others. When calling from C, the difference is very little because
they should have been copied (probably, was unsafe if not). I believe
these are the changes which actually fixed the crash.

This started with enhancing tags, but when I was done I discovered a
sigsev which could be triggered even from Rust code. I knew I had
screwed up the lifetimes and unsafe code.

So, I started working and I kept unravelling more and more.

Slice and vec have been split into their own files as lib.rs was
getting large.

Tags are now optional. Some strings have changed to be Cow<str>.

Many From traits were changed to work with &T instead of T because of
lifetime issues.
The other string is only borrowed temporarily.

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable! Probably worth having some else also give a second run-through to make sure the Rust-fu is tight, but I like it 👍

Comment thread ddprof-exporter/src/lib.rs Outdated
Comment thread ddprof-exporter/src/lib.rs Outdated
Comment thread ddprof-exporter/src/tag.rs Outdated
Comment thread ddprof-exporter/src/tag.rs Outdated
Comment thread ddprof-ffi/src/slice.rs Outdated
Comment thread ddprof-ffi/src/slice.rs Outdated
Comment thread ddprof-ffi/src/slice.rs Outdated
morrisonlevi and others added 2 commits April 11, 2022 08:30
It ended up being slighly less lines than duplicating the code.

Also run cargo format -- a contrib made in the GitHub UI wasn't quite
formatted correctly.
@morrisonlevi
morrisonlevi merged commit 9989036 into main Apr 12, 2022
@morrisonlevi
morrisonlevi deleted the levi/cleanup branch April 12, 2022 16:29
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.

2 participants