]> git.sesse.net Git - casparcg/blobdiff - common/page_locked_allocator.h
set svn:eol-style native on .h and .cpp files
[casparcg] / common / page_locked_allocator.h
index 9cce6e8f87899fac36fdd19087dd349a2aba96fb..9a4d72a3b9193889ba0c48a285fe3a94e6e6bb97 100644 (file)
@@ -1,75 +1,75 @@
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#pragma once\r
-\r
-namespace caspar {\r
-\r
-namespace detail {\r
-\r
-void* alloc_page_locked(size_t size);\r
-void free_page_locked(void* p);\r
-\r
-}\r
-       \r
-template <class T>\r
-class page_locked_allocator\r
-{\r
-public:\r
-       typedef size_t    size_type;\r
-       typedef ptrdiff_t difference_type;\r
-       typedef T*        pointer;\r
-       typedef const T*  const_pointer;\r
-       typedef T&        reference;\r
-       typedef const T&  const_reference;\r
-       typedef T         value_type;\r
-\r
-       page_locked_allocator() {}\r
-       page_locked_allocator(const page_locked_allocator&) {}\r
-  \r
-       pointer allocate(size_type n, const void * = 0) \r
-       {\r
-               return reinterpret_cast<T*>(detail::alloc_page_locked(n));\r
-       }\r
-  \r
-       void deallocate(void* p, size_type) \r
-       {\r
-               detail::free_page_locked(p);            \r
-       }\r
-\r
-       pointer           address(reference x) const { return &x; }\r
-       const_pointer     address(const_reference x) const { return &x; }\r
-       page_locked_allocator<T>&  operator=(const page_locked_allocator&) { return *this; }\r
-       void              construct(pointer p, const T& val) { new ((T*) p) T(val); }\r
-       void              destroy(pointer p) { p->~T(); }\r
-\r
-       size_type         max_size() const { return size_t(-1); }\r
-\r
-       template <class U>\r
-       struct rebind { typedef page_locked_allocator<U> other; };\r
-\r
-       template <class U>\r
-       page_locked_allocator(const page_locked_allocator<U>&) {}\r
-\r
-       template <class U>\r
-       page_locked_allocator& operator=(const page_locked_allocator<U>&) { return *this; }\r
-};\r
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+namespace caspar {
+
+namespace detail {
+
+void* alloc_page_locked(size_t size);
+void free_page_locked(void* p);
+
+}
+       
+template <class T>
+class page_locked_allocator
+{
+public:
+       typedef size_t    size_type;
+       typedef ptrdiff_t difference_type;
+       typedef T*        pointer;
+       typedef const T*  const_pointer;
+       typedef T&        reference;
+       typedef const T&  const_reference;
+       typedef T         value_type;
+
+       page_locked_allocator() {}
+       page_locked_allocator(const page_locked_allocator&) {}
+  
+       pointer allocate(size_type n, const void * = 0) 
+       {
+               return reinterpret_cast<T*>(detail::alloc_page_locked(n));
+       }
+  
+       void deallocate(void* p, size_type) 
+       {
+               detail::free_page_locked(p);            
+       }
+
+       pointer           address(reference x) const { return &x; }
+       const_pointer     address(const_reference x) const { return &x; }
+       page_locked_allocator<T>&  operator=(const page_locked_allocator&) { return *this; }
+       void              construct(pointer p, const T& val) { new ((T*) p) T(val); }
+       void              destroy(pointer p) { p->~T(); }
+
+       size_type         max_size() const { return size_t(-1); }
+
+       template <class U>
+       struct rebind { typedef page_locked_allocator<U> other; };
+
+       template <class U>
+       page_locked_allocator(const page_locked_allocator<U>&) {}
+
+       template <class U>
+       page_locked_allocator& operator=(const page_locked_allocator<U>&) { return *this; }
+};
 }
\ No newline at end of file