nfc_context_new(): replace err() by return, problem still in nfc_init()!!
Not a good idea to call exit() from a library... Problem is now moved to void nfc_init() calling exit() This requires a change in API to return error rather than exiting...
This commit is contained in:
parent
09ef2e3927
commit
ae6062e5ba
2 changed files with 6 additions and 2 deletions
|
@ -68,7 +68,7 @@ nfc_context_new(void)
|
||||||
nfc_context *res = malloc(sizeof(*res));
|
nfc_context *res = malloc(sizeof(*res));
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
err(EXIT_FAILURE, "nfc_context_new: malloc");
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default context values
|
// Set default context values
|
||||||
|
|
|
@ -172,7 +172,11 @@ void
|
||||||
nfc_init(nfc_context **context)
|
nfc_init(nfc_context **context)
|
||||||
{
|
{
|
||||||
*context = nfc_context_new();
|
*context = nfc_context_new();
|
||||||
|
if (!context) {
|
||||||
|
perror("malloc");
|
||||||
|
// TODO: not a good idea to call exit() from a library, we should change API and return error
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
if (!nfc_drivers)
|
if (!nfc_drivers)
|
||||||
nfc_drivers_init();
|
nfc_drivers_init();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue