Debian Codegraph @

tools/fuzzing/registry/FuzzerRegistry.cpp

raw
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * * This Source Code Form is subject to the terms of the Mozilla Public
3 * * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "FuzzerRegistry.h"
7
8 namespace mozilla {
9
10 FuzzerRegistry& FuzzerRegistry::getInstance() {
11 static FuzzerRegistry instance;
12 return instance;
13 }
14
15 void FuzzerRegistry::registerModule(std::string moduleName,
16 FuzzerInitFunc initFunc,
17 FuzzerTestingFunc testingFunc) {
18 moduleMap.insert(std::pair<std::string, FuzzerFunctions>(
19 moduleName, FuzzerFunctions(initFunc, testingFunc)));
20 }
21
22 FuzzerFunctions FuzzerRegistry::getModuleFunctions(std::string& moduleName) {
23 return moduleMap[moduleName];
24 }
25
26 void FuzzerRegistry::printModuleNames() {
27 for (const auto& entry : moduleMap) {
28 printf("%s\n", entry.first.c_str());
29 }
30 }
31
32 } // namespace mozilla