]> src.bluestatic.org Git - zcpointer.git/log
zcpointer.git
7 years agoIn OwnedPtrDeleter<T>, store a vptr for a behavior function. master
Robert Sesek [Sun, 1 Jan 2017 07:07:19 +0000 (02:07 -0500)]
In OwnedPtrDeleter<T>, store a vptr for a behavior function.

Storing the behavior enum value results in more generated code, since the call
operator needs to perform a comparison.

8 years agoAdd a test for unwrapping member<T>.
Robert Sesek [Wed, 12 Oct 2016 01:41:16 +0000 (21:41 -0400)]
Add a test for unwrapping member<T>.

8 years agoMove the message for internal::RaiseUseAfterFree to the implementation.
Robert Sesek [Wed, 12 Oct 2016 01:32:34 +0000 (21:32 -0400)]
Move the message for internal::RaiseUseAfterFree to the implementation.

8 years agoMake member<T> not heap-allocated with ZCPOINTER_TRACK_REFS.
Robert Sesek [Wed, 12 Oct 2016 01:23:08 +0000 (21:23 -0400)]
Make member<T> not heap-allocated with ZCPOINTER_TRACK_REFS.

Instead, member<T> is a subclass of T with |operator&| overloaded. And a new
OwnershipBehavior field is added to the OwnedPtrDeleter, to control whether
delete should be invoked on the pointer. For member<T>, the behavior is to not,
while for owned<T> the behavior is to delete.

The new field does increase codesize for member<T> when using TRACK_REFS, since
the extra field is added to all deleters and requires an extra comparison. It is
not possible to do this using a compile-time-only mechansim because templates are
not covariant. That would prevent |owned<T, DELETE>| and |member<T, BORROW>|
from both returning a |ref<T>| even if DELETE and BORROW parameters were related.

But this also makes non-TRACK_REFS mode member<T> just a type alias for T, which
is more conceptually correct.

8 years agoAdd member<T> for non-pointer member varibables and stack locals.
Robert Sesek [Mon, 10 Oct 2016 18:56:42 +0000 (14:56 -0400)]
Add member<T> for non-pointer member varibables and stack locals.

8 years agoAdd a .gitignore for build output.
Robert Sesek [Sun, 9 Oct 2016 05:03:38 +0000 (01:03 -0400)]
Add a .gitignore for build output.

8 years agoAdd file-line information to test failure messages.
Robert Sesek [Sun, 9 Oct 2016 04:29:18 +0000 (00:29 -0400)]
Add file-line information to test failure messages.

For EXPECT_UAF, attempt to catch exceptions in non-ZCPOINTER_TRACK_REFS mode,
in case the stdlib throws one.

8 years agoIn tests, do not expect zero-cost mode to catch UAF.
Robert Sesek [Sun, 9 Oct 2016 04:01:06 +0000 (00:01 -0400)]
In tests, do not expect zero-cost mode to catch UAF.

Also differentiate pass/faile output and add a `make test` target.

8 years agoAdd a test for ref and owned in std::vector.
Robert Sesek [Sun, 9 Oct 2016 01:03:01 +0000 (21:03 -0400)]
Add a test for ref and owned in std::vector.

8 years agoref<T>::ref() now initializes to nullptr. Improve boolean comparisons for ref.
Robert Sesek [Sun, 9 Oct 2016 00:54:21 +0000 (20:54 -0400)]
ref<T>::ref() now initializes to nullptr. Improve boolean comparisons for ref.

Also add internal::OwnedPtrDeleter::operator= to suport std::move of owned.

8 years agoIntroduce a basic EXPECT() and EXPECT_UAF() to test.cc.
Robert Sesek [Sun, 9 Oct 2016 00:44:50 +0000 (20:44 -0400)]
Introduce a basic EXPECT() and EXPECT_UAF() to test.cc.

8 years agoAdd a Suggested Usage section to the README.
Robert Sesek [Sat, 8 Oct 2016 22:17:18 +0000 (18:17 -0400)]
Add a Suggested Usage section to the README.

8 years agoThrow a custom exception type and attempt to catch it in the test program.
Robert Sesek [Sat, 8 Oct 2016 21:56:52 +0000 (17:56 -0400)]
Throw a custom exception type and attempt to catch it in the test program.

This allows all the tests to run. It is possible to inspect the exception by
breaking on __cxa_throw.

8 years agoFix ref<T>::~ref to not try to RemoveRef if already deleted.
Robert Sesek [Sat, 8 Oct 2016 21:55:40 +0000 (17:55 -0400)]
Fix ref<T>::~ref to not try to RemoveRef if already deleted.

Caught by TestReset.

8 years agoRemove unnecessary owned<T>::GetRawPointer().
Robert Sesek [Sat, 8 Oct 2016 21:30:25 +0000 (17:30 -0400)]
Remove unnecessary owned<T>::GetRawPointer().

8 years agoReduce the size of ref<T> to a single pointer.
Robert Sesek [Sat, 8 Oct 2016 21:23:27 +0000 (17:23 -0400)]
Reduce the size of ref<T> to a single pointer.

Rather than tracking |T*|, |OwnedPtrDeleter<T>|, and a |bool|; ref<T> now just
holds an |owned<T>*|. It uses uintptr_t's max value as a deletion sentinel
rather than a separate flag. And with the actual owned<T>*, the deleter doesn't
need to be held separately either.

8 years agoAdd a README.
Robert Sesek [Sat, 8 Oct 2016 20:14:29 +0000 (16:14 -0400)]
Add a README.

8 years agoFix ref::operator= for non-const lvalue binding to a temporary.
Robert Sesek [Sat, 8 Oct 2016 19:29:59 +0000 (15:29 -0400)]
Fix ref::operator= for non-const lvalue binding to a temporary.

Implement operator= manually and reimplement the copy-ctor using it, rather than
vice versa. In addition, deleter_ gets changed to a pointer rather than
reference, so that a default ctor can be added.

8 years agoMove exception raising into a .cc file so that -fno-exceptions can be used with the...
Robert Sesek [Sat, 8 Oct 2016 19:29:27 +0000 (15:29 -0400)]
Move exception raising into a .cc file so that -fno-exceptions can be used with the header.

8 years agoAdd a Makefile.
Robert Sesek [Sat, 8 Oct 2016 18:59:18 +0000 (14:59 -0400)]
Add a Makefile.

8 years agoMake ref(owned<T>) explicit.
Robert Sesek [Sat, 8 Oct 2016 18:48:57 +0000 (14:48 -0400)]
Make ref(owned<T>) explicit.

8 years agoInitial implementation of zero-cost unique_ptr with exploding weak references.
Robert Sesek [Sat, 8 Oct 2016 18:16:46 +0000 (14:16 -0400)]
Initial implementation of zero-cost unique_ptr with exploding weak references.