Skip to content

Commit 4025752

Browse files
tannewtdhalbert
andauthored
Apply suggestions from code review
Co-authored-by: Dan Halbert <[email protected]>
1 parent a6dd85c commit 4025752

File tree

9 files changed

+18
-0
lines changed

9 files changed

+18
-0
lines changed

py/objarray.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static mp_obj_array_t *array_new(char typecode, size_t n) {
120120
o->free = 0;
121121
o->len = n;
122122
// CIRCUITPY-CHANGE
123+
// CIRCUITPY-CHANGE
123124
o->items = m_malloc(typecode_size * o->len);
124125
return o;
125126
}
@@ -229,6 +230,7 @@ static mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args,
229230
#if MICROPY_PY_BUILTINS_MEMORYVIEW
230231

231232
mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) {
233+
// CIRCUITPY-CHANGE
232234
// CIRCUITPY-CHANGE
233235
mp_obj_array_t *self = mp_obj_malloc(mp_obj_array_t, &mp_type_memoryview);
234236
mp_obj_memoryview_init(self, typecode, 0, nitems, items);
@@ -690,6 +692,7 @@ static mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
690692
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("memoryview offset too large"));
691693
}
692694
// CIRCUITPY-CHANGE
695+
// CIRCUITPY-CHANGE
693696
res = mp_obj_malloc(mp_obj_array_t, &mp_type_memoryview);
694697
*res = *o;
695698
res->memview_offset += slice.start;

py/objclosure.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
5151
} else {
5252
// use heap to allocate temporary args array
5353
// CIRCUITPY-CHANGE
54+
// CIRCUITPY-CHANGE
5455
mp_obj_t *args2 = m_malloc_items(n_total);
5556
memcpy(args2, self->closed, self->n_closed * sizeof(mp_obj_t));
5657
memcpy(args2 + self->n_closed, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t));

py/objdeque.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t
5959
o->alloc = maxlen + 1;
6060
o->i_get = o->i_put = 0;
6161
// CIRCUITPY-CHANGE
62+
// CIRCUITPY-CHANGE
6263
o->items = m_malloc_items(o->alloc);
6364

6465
if (n_args > 2) {

py/objexcept.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in) {
9494
mp_int_t size = mp_obj_get_int(size_in);
9595
void *buf = NULL;
9696
if (size > 0) {
97+
// CIRCUITPY-CHANGE
9798
// CIRCUITPY-CHANGE
9899
buf = m_malloc_with_collect(size);
99100
}
@@ -222,6 +223,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz
222223

223224
// Try to allocate memory for the exception, with fallback to emergency exception object
224225
// CIRCUITPY-CHANGE
226+
// CIRCUITPY-CHANGE
225227
mp_obj_exception_t *o_exc = m_malloc_maybe_with_collect(sizeof(mp_obj_exception_t));
226228
if (o_exc == NULL) {
227229
o_exc = &MP_STATE_VM(mp_emergency_exception_obj);
@@ -546,6 +548,7 @@ mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, mp_rom_er
546548
// CIRCUITPY-CHANGE: here and more below
547549
size_t o_str_alloc = decompress_length(fmt);
548550
if (gc_alloc_possible()) {
551+
// CIRCUITPY-CHANGE
549552
// CIRCUITPY-CHANGE
550553
o_str = m_malloc_maybe_with_collect(sizeof(mp_obj_str_t));
551554
o_str_buf = m_new_maybe(byte, o_str_alloc);
@@ -664,6 +667,7 @@ void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qs
664667

665668
// Try to allocate memory for the traceback, with fallback to emergency traceback object
666669
if (self->traceback == NULL || self->traceback == (mp_obj_traceback_t *)&mp_const_empty_traceback_obj) {
670+
// CIRCUITPY-CHANGE
667671
// CIRCUITPY-CHANGE
668672
self->traceback = m_malloc_maybe_with_collect(sizeof(mp_obj_traceback_t));
669673
if (self->traceback == NULL) {

py/objtuple.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
8787
size_t alloc = 4;
8888
size_t len = 0;
8989
// CIRCUITPY-CHANGE
90+
// CIRCUITPY-CHANGE
9091
mp_obj_t *items = m_malloc_items(alloc);
9192

9293
mp_obj_t iterable = mp_getiter(args[0], NULL);

py/objtype.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *pos_args
9696
pos_args++;
9797
n_args--;
9898

99+
// CIRCUITPY-CHANGE
99100
// CIRCUITPY-CHANGE
100101
mp_obj_t *args2 = m_malloc_items(n_args + 2 * n_kw);
101102
// copy in args
@@ -341,6 +342,7 @@ static mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_arg
341342
mp_obj_t args2[1] = {MP_OBJ_FROM_PTR(self)};
342343
new_ret = mp_call_function_n_kw(init_fn[0], 1, 0, args2);
343344
} else {
345+
// CIRCUITPY-CHANGE
344346
// CIRCUITPY-CHANGE
345347
mp_obj_t *args2 = m_malloc_items(1 + n_args + 2 * n_kw);
346348
args2[0] = MP_OBJ_FROM_PTR(self);
@@ -373,6 +375,7 @@ static mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_arg
373375
if (n_args == 0 && n_kw == 0) {
374376
init_ret = mp_call_method_n_kw(0, 0, init_fn);
375377
} else {
378+
// CIRCUITPY-CHANGE
376379
// CIRCUITPY-CHANGE
377380
mp_obj_t *args2 = m_malloc_items(2 + n_args + 2 * n_kw);
378381
args2[0] = init_fn[0];
@@ -1516,6 +1519,7 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type
15161519
/******************************************************************************/
15171520
// staticmethod and classmethod types (probably should go in a different file)
15181521

1522+
// CIRCUITPY-CHANGE: better arg name
15191523
// CIRCUITPY-CHANGE: better arg name
15201524
static mp_obj_t static_class_method_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
15211525
assert(type == &mp_type_staticmethod || type == &mp_type_classmethod);

py/parse.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ static void *parser_alloc(parser_t *parser, size_t num_bytes) {
287287
alloc = num_bytes;
288288
}
289289
// CIRCUITPY-CHANGE
290+
// CIRCUITPY-CHANGE
290291
chunk = (mp_parse_chunk_t *)m_malloc_with_collect(sizeof(mp_parse_chunk_t) + alloc);
291292
chunk->alloc = alloc;
292293
chunk->union_.used = 0;
@@ -1056,6 +1057,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
10561057
parser.result_stack_top = 0;
10571058
parser.result_stack = NULL;
10581059
while (parser.result_stack_alloc > 1) {
1060+
// CIRCUITPY-CHANGE
10591061
// CIRCUITPY-CHANGE
10601062
parser.result_stack = m_malloc_maybe_with_collect(sizeof(mp_parse_node_t) * parser.result_stack_alloc);
10611063
if (parser.result_stack != NULL) {

py/scope.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, mp_uint_t emit_options
5151
MP_STATIC_ASSERT(MP_QSTR__lt_setcomp_gt_ <= UINT8_MAX);
5252
MP_STATIC_ASSERT(MP_QSTR__lt_genexpr_gt_ <= UINT8_MAX);
5353

54+
// CIRCUITPY-CHANGE
5455
// CIRCUITPY-CHANGE
5556
scope_t *scope = m_new_struct_with_collect(scope_t, 1);
5657
scope->kind = kind;

shared-bindings/displayio/Group.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ static mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu
318318
static mp_obj_t displayio_group_obj_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
319319
displayio_group_t *self = native_group(pos_args[0]);
320320
// CIRCUITPY-CHANGE
321+
// CIRCUITPY-CHANGE
321322
mp_obj_t *args = m_malloc_items(n_args);
322323
for (size_t i = 1; i < n_args; ++i) {
323324
args[i] = pos_args[i];

0 commit comments

Comments
 (0)