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:
parent
4228899f59
commit
ade8619ea6
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user