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:
Philippe Teuwen 2013-03-05 20:03:19 +01:00
parent 09ef2e3927
commit ae6062e5ba
2 changed files with 6 additions and 2 deletions

View file

@ -68,7 +68,7 @@ nfc_context_new(void)
nfc_context *res = malloc(sizeof(*res));
if (!res) {
err(EXIT_FAILURE, "nfc_context_new: malloc");
return NULL;
}
// Set default context values

View file

@ -172,7 +172,11 @@ void
nfc_init(nfc_context **context)
{
*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)
nfc_drivers_init();
}