spectrum: GetPointer not needed for dereferencing

Dereferencing the smart pointer is needed to pass it as an argument to
the Integral method, but by calling GetPointer to first obtain a raw
pointer, the automatic reference counting is disrupted, and the memory
will not be freed as expected.  Instead, dereference the smart pointer
directly.
This commit is contained in:
Tom Henderson
2016-08-25 09:56:50 -07:00
parent 5574e8af5f
commit 5c2df9acbf
2 changed files with 16 additions and 16 deletions

View File

@@ -130,8 +130,8 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
}
}
NS_LOG_DEBUG ("Added signal power to subbands 36-63 and 65-92");
NS_LOG_DEBUG ("Integrated power " << Integral (*(GetPointer (c))));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*(GetPointer (c)))) < 1e-6, "Power allocation failed");
NS_LOG_DEBUG ("Integrated power " << Integral (*c));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
break;
case 40:
// 112 subcarriers (104 data + 8 pilot)
@@ -146,8 +146,8 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
}
}
NS_LOG_DEBUG ("Added signal power to subbands 36-63, 65-92, 100-127, and 129-156");
NS_LOG_DEBUG ("Integrated power " << Integral (*(GetPointer (c))));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*(GetPointer (c)))) < 1e-6, "Power allocation failed");
NS_LOG_DEBUG ("Integrated power " << Integral (*c));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
break;
case 80:
// 224 subcarriers (208 data + 16 pilot)
@@ -165,8 +165,8 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
}
}
NS_LOG_DEBUG ("Added signal power to subbands 36-63, 65-92, 100-127, 129-156, 164-191, 193-220, 228-255, 257-284");
NS_LOG_DEBUG ("Integrated power " << Integral (*(GetPointer (c))));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*(GetPointer (c)))) < 1e-6, "Power allocation failed");
NS_LOG_DEBUG ("Integrated power " << Integral (*c));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
break;
case 160:
// 448 subcarriers (416 data + 32 pilot) VHT
@@ -188,8 +188,8 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
}
}
NS_LOG_DEBUG ("Added signal power to subbands 36-63, 65-92, 100-127, 129-156, 164-191, 193-220, 228-255, 257-284, 292-319, 321-348, 356-383, 385-412, 420-447, 449-476, 484-511, and 513-540");
NS_LOG_DEBUG ("Integrated power " << Integral (*(GetPointer (c))));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*(GetPointer (c)))) < 1e-6, "Power allocation failed");
NS_LOG_DEBUG ("Integrated power " << Integral (*c));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
break;
default:
NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
@@ -227,8 +227,8 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque
}
}
NS_LOG_DEBUG ("Added signal power to subbands 38-63 and 65-90");
NS_LOG_DEBUG ("Integrated power " << Integral (*(GetPointer (c))));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*(GetPointer (c)))) < 1e-6, "Power allocation failed");
NS_LOG_DEBUG ("Integrated power " << Integral (*c));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
break;
case 10:
// 28 subcarriers (24 data + 4 pilot)
@@ -249,8 +249,8 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque
}
}
NS_LOG_DEBUG ("Added signal power to subbands 34-47 and 49-62");
NS_LOG_DEBUG ("Integrated power " << Integral (*(GetPointer (c))));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*(GetPointer (c)))) < 1e-6, "Power allocation failed");
NS_LOG_DEBUG ("Integrated power " << Integral (*c));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
break;
case 5:
// 16 subcarriers (12 data + 4 pilot)
@@ -271,8 +271,8 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque
}
}
NS_LOG_DEBUG ("Added signal power to subbands 32-39 and 41-48");
NS_LOG_DEBUG ("Integrated power " << Integral (*(GetPointer (c))));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*(GetPointer (c)))) < 1e-6, "Power allocation failed");
NS_LOG_DEBUG ("Integrated power " << Integral (*c));
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
break;
default:
NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
@@ -325,7 +325,7 @@ WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (double noiseFigureDb,
Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (spectrumModel);
(*noisePsd) = noisePowerSpectralDensity;
NS_LOG_DEBUG ("NoisePowerSpectralDensity has integrated power of " << Integral (*(GetPointer (noisePsd))));
NS_LOG_DEBUG ("NoisePowerSpectralDensity has integrated power of " << Integral (*noisePsd));
return noisePsd;
}

View File

@@ -375,7 +375,7 @@ SpectrumWifiPhy::StartRx (Ptr<SpectrumSignalParameters> rxParams)
{
senderNodeId = rxParams->txPhy->GetDevice ()->GetNode ()->GetId ();
}
NS_LOG_DEBUG ("Received signal from " << senderNodeId << " with unfiltered power " << WToDbm (Integral (*(GetPointer (receivedSignalPsd)))) << " dBm");
NS_LOG_DEBUG ("Received signal from " << senderNodeId << " with unfiltered power " << WToDbm (Integral (*receivedSignalPsd)) << " dBm");
// Integrate over our receive bandwidth (i.e., all that the receive
// spectral mask representing our filtering allows) to find the
// total energy apparent to the "demodulator".