// If the numuber of the registered listeners is only one - most of cases, do shallow copy for better performance.
// Otherwise, do deep copy.
- // TODO: the following code should be applied after testing _Event::GetListenerCount() to work fine
-// if (_Event::GetListenerCount() == 1)
-// {
-// pDstMessage = _NdefMessageImpl::GetCloneSharingPayloadN(*pSrcMessage);
-// SysTryReturnVoidResult(NID_NET_NFC, pDstMessage != null, GetLastResult(),
-// "[%s] Copying an NDEF message failed.", GetErrorMessage(GetLastResult()));
-// }
-// else
-// {
+ if (_Event::GetListenerCount() == 1)
+ {
+ pDstMessage = _NdefMessageImpl::GetCloneSharingPayloadN(*pSrcMessage);
+ SysTryReturnVoidResult(NID_NET_NFC, pDstMessage != null, GetLastResult(),
+ "[%s] Copying an NDEF message failed.", GetErrorMessage(GetLastResult()));
+ }
+ else
+ {
pDstMessage = new (std::nothrow) NdefMessage(*pSrcMessage); // deep copy
SysTryReturnVoidResult(NID_NET_NFC, pDstMessage != null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] Memory allocation failed.");
-// }
+ }
pEventListener->OnNdefMessageDetectedN(pDstMessage); // transfer the ownershipt to the listener
}