Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Unified Diff: mojo/system/memory.cc

Issue 25323003: Mojo: Optimize VerifyUserPointer(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/memory.h ('k') | mojo/system/message_pipe.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/memory.cc
diff --git a/mojo/system/memory.cc b/mojo/system/memory.cc
index df658ae5ee3d405aff88f8f244259583f22f81b3..fe7edef3da3f4a3871171a19f197c65d4e2b70c6 100644
--- a/mojo/system/memory.cc
+++ b/mojo/system/memory.cc
@@ -11,9 +11,9 @@
namespace mojo {
namespace system {
-bool VerifyUserPointer(const void* pointer, size_t count, size_t size_each) {
- DCHECK_GT(size_each, 0u);
- if (count > std::numeric_limits<size_t>::max() / size_each)
+template <size_t size>
+bool VerifyUserPointerForSize(const void* pointer, size_t count) {
+ if (count > std::numeric_limits<size_t>::max() / size)
return false;
// TODO(vtl): If running in kernel mode, do a full verification. For now, just
@@ -22,5 +22,9 @@ bool VerifyUserPointer(const void* pointer, size_t count, size_t size_each) {
return count == 0 || !!pointer;
}
+// Explicitly instantiate the sizes we need. Add instantiations as needed.
+template bool VerifyUserPointerForSize<1>(const void*, size_t);
+template bool VerifyUserPointerForSize<4>(const void*, size_t);
+
} // namespace system
} // namespace mojo
« no previous file with comments | « mojo/system/memory.h ('k') | mojo/system/message_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698