本文整理汇总了C++中MemoryManager::free方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryManager::free方法的具体用法?C++ MemoryManager::free怎么用?C++ MemoryManager::free使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryManager
的用法示例。
在下文中一共展示了MemoryManager::free方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
void process() {
while(nextOperation) {
auto operation = nextOperation;
switch(operation->type) {
case OperationType::Add: onAdd(operation); break;
case OperationType::Remove: onRemove(operation); break;
case OperationType::RemoveAll: onRemoveAll(operation); break;
default:
throw std::runtime_error("Unexpected EntityOperation type");
}
nextOperation = operation->nextOperation;
operation->~T();
memoryManager->free(sizeof(T), alignof(T), operation);
}
nextOperation = nullptr;
lastOperation = nullptr;
}
示例2: execute
void execute(string line, MemoryManager &memManager) {
string funcName = parseFunction(line);
if (funcName.compare("alloc") == 0) {
int pid;
UNIT size = getAllocParam(line, &pid);
if (!size) {
cout << "Parse parameters error: " << line << endl;
} else {
if (!memManager.alloc(pid, size)) {
cout << "No space for process " << pid << endl;
}
}
} else if (funcName.compare("realloc") == 0) {
int pid;
UNIT size = getReallocParam(line, &pid);
if (!size) {
cout << "Parse parameters error: " << line << endl;
} else {
if (!memManager.realloc(pid, size)) {
cout << "No space for process " << pid << endl;
}
}
} else if (funcName.compare("free") == 0) {
int pid = getFreeParam(line);
if (pid == -1) {
cout << "Parse parameters error: " << line << endl;
} else {
if (!memManager.free(pid)) {
cout << "Free: couldn't find process " << pid << endl;
}
}
} else if (funcName.compare("dump") == 0) {
memManager.dump();
} else {
cout << "Can not parse command: " << line << endl;
}
}