py/stream: Remove unnecessary checks for NULL return from vstr_add_len.

The vstr argument to the calls to vstr_add_len are dynamically allocated
(ie fixed_buf=false) and so vstr_add_len will never return NULL.  So
there's no need to check for it.  Any out-of-memory errors are raised by
the call to m_renew in vstr_ensure_extra.
This commit is contained in:
Damien George 2017-08-31 21:42:39 +10:00
parent 96fd80db13
commit 7885a425d7
1 changed files with 0 additions and 7 deletions

View File

@ -141,9 +141,6 @@ STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte fl
mp_uint_t last_buf_offset = 0;
while (more_bytes > 0) {
char *p = vstr_add_len(&vstr, more_bytes);
if (p == NULL) {
mp_raise_msg(&mp_type_MemoryError, "out of memory");
}
int error;
mp_uint_t out_sz = mp_stream_read_exactly(args[0], p, more_bytes, &error);
if (error != 0) {
@ -380,10 +377,6 @@ STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args)
while (max_size == -1 || max_size-- != 0) {
char *p = vstr_add_len(&vstr, 1);
if (p == NULL) {
mp_raise_msg(&mp_type_MemoryError, "out of memory");
}
int error;
mp_uint_t out_sz = stream_p->read(args[0], p, 1, &error);
if (out_sz == MP_STREAM_ERROR) {