copied everything over from 2012 and removed all of the actual robot code except the drivetrain stuff


git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4078 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/common/unique_malloc_ptr.h b/aos/common/unique_malloc_ptr.h
new file mode 100644
index 0000000..696b9f3
--- /dev/null
+++ b/aos/common/unique_malloc_ptr.h
@@ -0,0 +1,29 @@
+#include <memory>
+
+namespace aos {
+
+namespace {
+
+template<typename T, void(*function)(T *)>
+void const_wrap(const T *ptr) {
+  function(const_cast<T *>(ptr));
+}
+
+// Wrapper function to deal with the differences between C and C++ (C++ doesn't
+// automatically convert T* to void* like C).
+template<typename T>
+void free_type(T *ptr) { ::free(reinterpret_cast<void *>(ptr)); }
+
+}  // namespace
+
+// A std::unique_ptr that should get freed with a C-style free function
+// (free(2) by default).
+template<typename T, void(*function)(T *) = free_type>
+class unique_c_ptr : public std::unique_ptr<T, void(*)(const T *)> {
+ public:
+  unique_c_ptr(T *pointer)
+      : std::unique_ptr<T, void(*)(const T *)>(
+          pointer, const_wrap<T, function>) {}
+};
+
+}  // namespace aos