Don't assume malloc sets errno to ENOMEM.

Although many implementations (including glibc) set errno on failure,
this is not required by the C standard.
This commit is contained in:
Jef Driesen 2016-01-26 19:33:46 +01:00
parent 4228899f59
commit ade8619ea6
2 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ irda_socket_open (irda_t **out, dc_context_t *context)
#ifdef _WIN32
SYSERROR (context, ERROR_OUTOFMEMORY);
#else
SYSERROR (context, errno);
SYSERROR (context, ENOMEM);
#endif
return -1; // ENOMEM (Not enough space)
}

View File

@ -137,7 +137,7 @@ serial_open (serial_t **out, dc_context_t *context, const char* name)
// Allocate memory.
serial_t *device = (serial_t *) malloc (sizeof (serial_t));
if (device == NULL) {
SYSERROR (context, errno);
SYSERROR (context, ENOMEM);
return -1; // ENOMEM (Not enough space)
}