mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-04-11 00:56:18 +00:00
Convert by value passing of nfc_target to pointer for str_nfc_target and nfc_initiator_target_is_present
This becomes more consistent with all other pass by pointer of most structures. Additionally, this should lessen stack memory usage, as building strings with str_nfc_target would push the target (283 bytes) plus then a copy of the info objects (up to 275) onto the stack as it dives into the sprintf functions. Lastly, this makes my attempt at a .NET wrapper easier, as I can make passing by pointer work, but passing by value seems to bomb on the interop right now.
This commit is contained in:
committed by
Philippe Teuwen
parent
a262be5633
commit
c72846e3c6
@@ -821,9 +821,9 @@ nfc_initiator_transceive_bytes_timed(nfc_device *pnd,
|
||||
* @warning To run the test, one or more commands will be sent to target
|
||||
*/
|
||||
int
|
||||
nfc_initiator_target_is_present(nfc_device *pnd, const nfc_target nt)
|
||||
nfc_initiator_target_is_present(nfc_device *pnd, const nfc_target *pnt)
|
||||
{
|
||||
HAL(initiator_target_is_present, pnd, nt);
|
||||
HAL(initiator_target_is_present, pnd, pnt);
|
||||
}
|
||||
|
||||
/** @ingroup initiator
|
||||
@@ -1287,12 +1287,12 @@ str_nfc_modulation_type(const nfc_modulation_type nmt)
|
||||
* @warning *buf must be freed using nfc_free()
|
||||
*/
|
||||
int
|
||||
str_nfc_target(char **buf, const nfc_target nt, bool verbose)
|
||||
str_nfc_target(char **buf, const nfc_target *pnt, bool verbose)
|
||||
{
|
||||
*buf = malloc(4096);
|
||||
if (! *buf)
|
||||
return NFC_ESOFT;
|
||||
(*buf)[0] = '\0';
|
||||
snprint_nfc_target(*buf, 4096, nt, verbose);
|
||||
snprint_nfc_target(*buf, 4096, pnt, verbose);
|
||||
return strlen(*buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user