Ejemplo n.º 1
0
TVMStatus VMMemoryPoolQuery(TVMMemoryPoolID memory, TVMMemorySizeRef bytesLeft){
	TMachineSignalState sigState;	
	MachineSuspendSignals(&sigState);
	ThreadStore* tStore = ThreadStore::getInstance();

	if(bytesLeft == NULL){
		printf("VMMemoryPoolQuery(): bytesLeft is null\n");
		return VM_STATUS_ERROR_INVALID_PARAMETER;
	}
	
	MemoryPool *pool = tStore->findMemoryPoolByID(memory);

	if(pool == NULL){	//the memory pool was not found in the system
		printf("VMMemoryPoolQuery(): pool MID %d could not be found\n", memory);
		return VM_STATUS_ERROR_INVALID_PARAMETER;
	}

	*bytesLeft = pool->getNumberOfUnallocatedBytes();
	MachineResumeSignals(&sigState);
	return VM_STATUS_SUCCESS;
}