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

Unified Diff: courgette/program_detector.h

Issue 2055343002: Courgette: Add static method QuickDetect() to optimize program detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Propagate uint8_t* to unittests and Nits Created 4 years, 6 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
Index: courgette/program_detector.h
diff --git a/courgette/program_detector.h b/courgette/program_detector.h
index 06f1da3f84762791181742776de0d466ded7dec8..cce0a171ab4cb69d6e5c781ec1ba2d47138b0438 100644
--- a/courgette/program_detector.h
+++ b/courgette/program_detector.h
@@ -23,11 +23,21 @@ class AssemblyProgram;
// On failure:
// Fills in |type| with UNKNOWN, |detected_length| with 0, and returns
// C_INPUT_NOT_RECOGNIZED.
-Status DetectExecutableType(const void* buffer,
+Status DetectExecutableType(const uint8_t* buffer,
size_t length,
ExecutableType* type,
size_t* detected_length);
+// Same as above, takes void* instead.
+// TODO(etiennep): Propagate "const uint8_t*" upwards.
+inline Status DetectExecutableType(const void* buffer,
+ size_t length,
+ ExecutableType* type,
+ size_t* detected_length) {
+ return DetectExecutableType(reinterpret_cast<const uint8_t*>(buffer), length,
+ type, detected_length);
+}
+
// Attempts to detect the type of executable, and parse it with the appropriate
// tools.
// On success:
@@ -35,10 +45,20 @@ Status DetectExecutableType(const void* buffer,
// C_OK.
// On failure:
// Returns an error status and assigns |*output| to null.
-Status ParseDetectedExecutable(const void* buffer,
+Status ParseDetectedExecutable(const uint8_t* buffer,
size_t length,
std::unique_ptr<AssemblyProgram>* output);
+// Same as above, takes void* instead.
+// TODO(etiennep): Propagate "const uint8_t*" upwards.
+inline Status ParseDetectedExecutable(
+ const void* buffer,
+ size_t length,
+ std::unique_ptr<AssemblyProgram>* output) {
+ return ParseDetectedExecutable(reinterpret_cast<const uint8_t*>(buffer),
+ length, output);
+}
+
} // namespace courgette
#endif // COURGETTE_PROGRAM_DETECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698