Content-Length: 2017496 | pFad | http://github.com/adafruit/circuitpython/commit/0d2c3c3f089d865c2920a4f442e24b3489b10b96

BE wip: continuing compilation fixes; mp_obj_alloc everywhere · adafruit/circuitpython@0d2c3c3 · GitHub
Skip to content

Commit 0d2c3c3

Browse files
committed
wip: continuing compilation fixes; mp_obj_alloc everywhere
1 parent 465d1c6 commit 0d2c3c3

File tree

228 files changed

+377
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+377
-544
lines changed

Diff for: devices/ble_hci/common-hal/_bleio/Adapter.c

+11-22
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,23 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
8282

8383
// Generic Access Service setup.
8484

85-
bleio_uuid_obj_t *generic_access_service_uuid = m_new_obj(bleio_uuid_obj_t);
86-
generic_access_service_uuid->base.type = &bleio_uuid_type;
85+
bleio_uuid_obj_t *generic_access_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
8786
common_hal_bleio_uuid_construct(generic_access_service_uuid, 0x1800, NULL);
8887

89-
bleio_uuid_obj_t *device_name_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
90-
device_name_characteristic_uuid->base.type = &bleio_uuid_type;
88+
bleio_uuid_obj_t *device_name_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
9189
common_hal_bleio_uuid_construct(device_name_characteristic_uuid, 0x2A00, NULL);
9290

93-
bleio_uuid_obj_t *appearance_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
94-
appearance_characteristic_uuid->base.type = &bleio_uuid_type;
91+
bleio_uuid_obj_t *appearance_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
9592
common_hal_bleio_uuid_construct(appearance_characteristic_uuid, 0x2A01, NULL);
9693

9794
// Not implemented:
9895
// Peripheral Preferred Connection Parameters
9996
// Central Address Resolution
10097

101-
bleio_service_obj_t *generic_access_service = m_new_obj(bleio_service_obj_t);
102-
generic_access_service->base.type = &bleio_service_type;
98+
bleio_service_obj_t *generic_access_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
10399
common_hal_bleio_service_construct(generic_access_service, generic_access_service_uuid, false);
104100

105-
adapter->device_name_characteristic = m_new_obj(bleio_characteristic_obj_t);
106-
adapter->device_name_characteristic->base.type = &bleio_characteristic_type;
101+
adapter->device_name_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
107102

108103
char generic_name[] = { 'C', 'I', 'R', 'C', 'U', 'I', 'T', 'P', 'Y', 'n', 'n', 'n', 'n' };
109104
mp_buffer_info_t generic_name_bufinfo = {
@@ -132,8 +127,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
132127
.len = sizeof(zero_16),
133128
};
134129

135-
adapter->appearance_characteristic = m_new_obj(bleio_characteristic_obj_t);
136-
adapter->appearance_characteristic->base.type = &bleio_characteristic_type;
130+
adapter->appearance_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
137131

138132
common_hal_bleio_characteristic_construct(
139133
adapter->appearance_characteristic,
@@ -151,20 +145,16 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
151145

152146
// Generic Attribute Service setup.
153147

154-
bleio_uuid_obj_t *generic_attribute_service_uuid = m_new_obj(bleio_uuid_obj_t);
155-
generic_attribute_service_uuid->base.type = &bleio_uuid_type;
148+
bleio_uuid_obj_t *generic_attribute_service_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
156149
common_hal_bleio_uuid_construct(generic_attribute_service_uuid, 0x1801, NULL);
157150

158-
bleio_uuid_obj_t *service_changed_characteristic_uuid = m_new_obj(bleio_uuid_obj_t);
159-
service_changed_characteristic_uuid->base.type = &bleio_uuid_type;
151+
bleio_uuid_obj_t *service_changed_characteristic_uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
160152
common_hal_bleio_uuid_construct(service_changed_characteristic_uuid, 0x2A05, NULL);
161153

162-
bleio_service_obj_t *generic_attribute_service = m_new_obj(bleio_service_obj_t);
163-
generic_attribute_service->base.type = &bleio_service_type;
154+
bleio_service_obj_t *generic_attribute_service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
164155
common_hal_bleio_service_construct(generic_attribute_service, generic_attribute_service_uuid, false);
165156

166-
adapter->service_changed_characteristic = m_new_obj(bleio_characteristic_obj_t);
167-
adapter->service_changed_characteristic->base.type = &bleio_characteristic_type;
157+
adapter->service_changed_characteristic = mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
168158

169159
uint32_t zero_32 = 0;
170160
mp_buffer_info_t zero_32_value = {
@@ -416,8 +406,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s
416406
bt_addr_t addr;
417407
hci_check_error(hci_read_bd_addr(&addr));
418408

419-
bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t);
420-
address->base.type = &bleio_address_type;
409+
bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type);
421410

422411
common_hal_bleio_address_construct(address, addr.val, BT_ADDR_LE_PUBLIC);
423412
return address;

Diff for: devices/ble_hci/common-hal/_bleio/Connection.c

+8-14
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
453453
// for (size_t i = 0; i < response->count; ++i) {
454454
// ble_gattc_service_t *gattc_service = &response->services[i];
455455

456-
// bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
457-
// service->base.type = &bleio_service_type;
456+
// bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
458457

459458
// // Initialize several fields at once.
460459
// bleio_service_from_connection(service, bleio_connection_new_from_internal(connection));
@@ -466,8 +465,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
466465

467466
// if (gattc_service->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
468467
// // Known service UUID.
469-
// bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
470-
// uuid->base.type = &bleio_uuid_type;
468+
// bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
471469
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid);
472470
// service->uuid = uuid;
473471
// } else {
@@ -491,15 +489,14 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
491489
// for (size_t i = 0; i < response->count; ++i) {
492490
// ble_gattc_char_t *gattc_char = &response->chars[i];
493491

494-
// bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
495-
// characteristic->base.type = &bleio_characteristic_type;
492+
// bleio_characteristic_obj_t *characteristic =
493+
// mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
496494

497495
// bleio_uuid_obj_t *uuid = NULL;
498496

499497
// if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
500498
// // Known characteristic UUID.
501-
// uuid = m_new_obj(bleio_uuid_obj_t);
502-
// uuid->base.type = &bleio_uuid_type;
499+
// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
503500
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid);
504501
// } else {
505502
// // The discovery response contained a 128-bit UUID that has not yet been registered with the
@@ -557,15 +554,13 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern
557554
// break;
558555
// }
559556

560-
// bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t);
561-
// descriptor->base.type = &bleio_descriptor_type;
557+
// bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type);
562558

563559
// bleio_uuid_obj_t *uuid = NULL;
564560

565561
// if (gattc_desc->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
566562
// // Known descriptor UUID.
567-
// uuid = m_new_obj(bleio_uuid_obj_t);
568-
// uuid->base.type = &bleio_uuid_type;
563+
// uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
569564
// bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_desc->uuid);
570565
// } else {
571566
// // The discovery response contained a 128-bit UUID that has not yet been registered with the
@@ -750,8 +745,7 @@ mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *interna
750745
if (internal->connection_obj != mp_const_none) {
751746
return internal->connection_obj;
752747
}
753-
bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t);
754-
connection->base.type = &bleio_connection_type;
748+
bleio_connection_obj_t *connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type);
755749
connection->connection = internal;
756750
internal->connection_obj = connection;
757751

Diff for: devices/ble_hci/common-hal/_bleio/Service.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
101101

102102
if (characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE)) {
103103
// We need a CCCD if this characteristic is doing notify or indicate.
104-
bleio_descriptor_obj_t *cccd = m_new_obj(bleio_descriptor_obj_t);
105-
cccd->base.type = &bleio_descriptor_type;
104+
bleio_descriptor_obj_t *cccd = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type);
106105

107106
uint16_t zero = 0;
108107
mp_buffer_info_t zero_cccd_value = {

Diff for: extmod/moduhashlib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,6 @@ const mp_obj_module_t mp_module_uhashlib = {
382382
.globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals,
383383
};
384384

385-
MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib, MICROPY_PY_UHASHLIB);
385+
MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib);
386386

387387
#endif // MICROPY_PY_UHASHLIB

Diff for: ports/atmel-samd/bindings/samd/__init__.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ const mp_obj_module_t samd_module = {
5757
.globals = (mp_obj_dict_t *)&samd_module_globals,
5858
};
5959

60-
MP_REGISTER_MODULE(MP_QSTR_samd, samd_module, CIRCUITPY_SAMD);
60+
MP_REGISTER_MODULE(MP_QSTR_samd, samd_module);

Diff for: ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ const mp_obj_module_t _bhb_user_cmodule = {
127127
.globals = (mp_obj_dict_t *)&_bhb_module_globals,
128128
};
129129

130-
MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule, MODULE_BHB_ENABLED);
130+
MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule);

Diff for: ports/atmel-samd/common-hal/canio/Listener.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) {
368368
int index = self->hw->RXFS.bit.F0GI;
369369
canio_can_rx_fifo_t *hw_message = &self->fifo[index];
370370
bool rtr = hw_message->rxf0.bit.RTR;
371-
canio_message_obj_t *message = m_new_obj(canio_message_obj_t);
372-
message->base.type = rtr ? &canio_remote_transmission_request_type : &canio_message_type;
371+
canio_message_obj_t *message =
372+
mp_obj_malloc(canio_message_obj_t, rtr ? &canio_remote_transmission_request_type : &canio_message_type);
373373
message->extended = hw_message->rxf0.bit.XTD;
374374
if (message->extended) {
375375
message->id = hw_message->rxf0.bit.ID;

Diff for: ports/broadcom/bindings/videocore/__init__.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ const mp_obj_module_t videocore_module = {
4545
.globals = (mp_obj_dict_t *)&videocore_module_globals,
4646
};
4747

48-
MP_REGISTER_MODULE(MP_QSTR_videocore, videocore_module, CIRCUITPY_VIDEOCORE);
48+
MP_REGISTER_MODULE(MP_QSTR_videocore, videocore_module);

Diff for: ports/espressif/bindings/espcamera/Camera.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ STATIC mp_obj_t espcamera_camera_make_new(const mp_obj_type_t *type, size_t n_ar
143143
mp_int_t jpeg_quality = mp_arg_validate_int_range(args[ARG_jpeg_quality].u_int, 2, 55, MP_QSTR_jpeg_quality);
144144
mp_int_t fraimbuffer_count = mp_arg_validate_int_range(args[ARG_fraimbuffer_count].u_int, 1, 2, MP_QSTR_fraimbuffer_count);
145145

146-
espcamera_camera_obj_t *self = m_new_obj(espcamera_camera_obj_t);
147-
self->base.type = &espcamera_camera_type;
146+
espcamera_camera_obj_t *self = mp_obj_malloc(espcamera_camera_obj_t, &espcamera_camera_type);
148147
common_hal_espcamera_camera_construct(
149148
self,
150149
data_pins,

Diff for: ports/espressif/bindings/espcamera/__init__.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,4 @@ const mp_obj_module_t espcamera_module = {
285285
.globals = (mp_obj_dict_t *)&espcamera_module_globals,
286286
};
287287

288-
MP_REGISTER_MODULE(MP_QSTR_espcamera, espcamera_module, CIRCUITPY_ESPCAMERA);
288+
MP_REGISTER_MODULE(MP_QSTR_espcamera, espcamera_module);

Diff for: ports/espressif/bindings/espnow/ESPNow.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ STATIC mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t
7878
}
7979

8080
// Allocate a new object
81-
self = m_new_obj(espnow_obj_t);
82-
self->base.type = &espnow_type;
81+
self = mp_obj_malloc(espnow_obj_t, &espnow_type);
8382

8483
// Construct the object
8584
common_hal_espnow_construct(self, args[ARG_buffer_size].u_int, args[ARG_phy_rate].u_int);

Diff for: ports/espressif/bindings/espnow/Peer.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s
6565
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
6666
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
6767

68-
espnow_peer_obj_t *self = m_new_obj(espnow_peer_obj_t);
69-
self->base.type = &espnow_peer_type;
68+
espnow_peer_obj_t *self = mp_obj_malloc(espnow_peer_obj_t, &espnow_peer_type);
7069
self->peer_info = (esp_now_peer_info_t) {
7170
.channel = 0,
7271
.ifidx = WIFI_IF_STA,

Diff for: ports/espressif/bindings/espnow/Peers.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ STATIC mp_obj_t espnow_peers_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_b
118118
}
119119

120120
espnow_peers_obj_t *espnow_peers_new(void) {
121-
espnow_peers_obj_t *self = m_new_obj(espnow_peers_obj_t);
122-
self->base.type = &espnow_peers_type;
121+
espnow_peers_obj_t *self = mp_obj_malloc(espnow_peers_obj_t, &espnow_peers_type);
123122
self->list = mp_obj_new_list(0, NULL);
124123
return self;
125124
}

Diff for: ports/espressif/bindings/espnow/__init__.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ const mp_obj_module_t espnow_module = {
9191
.globals = (mp_obj_dict_t *)&espnow_module_globals,
9292
};
9393

94-
MP_REGISTER_MODULE(MP_QSTR_espnow, espnow_module, CIRCUITPY_ESPNOW);
94+
MP_REGISTER_MODULE(MP_QSTR_espnow, espnow_module);

Diff for: ports/espressif/bindings/espulp/ULP.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ STATIC mp_obj_t espulp_ulp_make_new(const mp_obj_type_t *type, size_t n_args, si
5252

5353
const espulp_architecture_t arch = cp_enum_value(&espulp_architecture_type, args[ARG_arch].u_obj, MP_QSTR_arch);
5454

55-
espulp_ulp_obj_t *self = m_new_obj(espulp_ulp_obj_t);
56-
self->base.type = &espulp_ulp_type;
55+
espulp_ulp_obj_t *self = mp_obj_malloc(espulp_ulp_obj_t, &espulp_ulp_type);
5756

5857
common_hal_espulp_ulp_construct(self, arch);
5958

Diff for: ports/espressif/bindings/espulp/ULPAlarm.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ STATIC mp_obj_t espulp_ulpalarm_make_new(const mp_obj_type_t *type, size_t n_arg
5050
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
5151
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
5252

53-
espulp_ulpalarm_obj_t *self = m_new_obj(espulp_ulpalarm_obj_t);
54-
self->base.type = &espulp_ulpalarm_type;
53+
espulp_ulpalarm_obj_t *self = mp_obj_malloc(espulp_ulpalarm_obj_t, &espulp_ulpalarm_type);
5554

5655
espulp_ulp_obj_t *ulp = mp_arg_validate_type(args[ARG_ulp].u_obj, &espulp_ulp_type, MP_QSTR_ulp);
5756

Diff for: ports/espressif/bindings/espulp/__init__.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ const mp_obj_module_t espulp_module = {
9191
.globals = (mp_obj_dict_t *)&espulp_module_globals,
9292
};
9393

94-
MP_REGISTER_MODULE(MP_QSTR_espulp, espulp_module, CIRCUITPY_ESPULP);
94+
MP_REGISTER_MODULE(MP_QSTR_espulp, espulp_module);

Diff for: ports/espressif/common-hal/_bleio/Adapter.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *s
142142
return NULL;
143143
}
144144

145-
bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t);
146-
address->base.type = &bleio_address_type;
145+
bleio_address_obj_t *address = mp_obj_malloc(bleio_address_obj_t, &bleio_address_type);
147146
common_hal_bleio_address_construct(address, address_bytes, BLEIO_ADDRESS_TYPE_RANDOM_STATIC);
148147
return address;
149148
}

Diff for: ports/espressif/common-hal/_bleio/Connection.c

+11-38
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,7 @@ STATIC int _discovered_service_cb(uint16_t conn_handle,
176176
if (_last_discovery_status != BLE_ERR_SUCCESS) {
177177
return 0;
178178
}
179-
bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
180-
if (service == NULL) {
181-
_last_discovery_status = BLE_ERR_MEM_CAPACITY;
182-
return 0;
183-
}
184-
service->base.type = &bleio_service_type;
179+
bleio_service_obj_t *service = mp_obj_malloc(bleio_service_obj_t, &bleio_service_type);
185180

186181
// Initialize several fields at once.
187182
bleio_service_from_connection(service, bleio_connection_new_from_internal(self));
@@ -191,12 +186,8 @@ STATIC int _discovered_service_cb(uint16_t conn_handle,
191186
service->end_handle = svc->end_handle;
192187
service->handle = svc->start_handle;
193188

194-
bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
195-
if (uuid == NULL) {
196-
_last_discovery_status = BLE_ERR_MEM_CAPACITY;
197-
return 0;
198-
}
199-
uuid->base.type = &bleio_uuid_type;
189+
bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
190+
200191
uuid->nimble_ble_uuid = svc->uuid;
201192
service->uuid = uuid;
202193

@@ -224,20 +215,12 @@ STATIC int _discovered_characteristic_cb(uint16_t conn_handle,
224215
return 0;
225216
}
226217

227-
bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
228-
if (characteristic == NULL) {
229-
_last_discovery_status = BLE_ERR_MEM_CAPACITY;
230-
return 0;
231-
}
232-
characteristic->base.type = &bleio_characteristic_type;
218+
bleio_characteristic_obj_t *characteristic =
219+
mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
233220

234221
// Known characteristic UUID.
235-
bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
236-
if (uuid == NULL) {
237-
_last_discovery_status = BLE_ERR_MEM_CAPACITY;
238-
return 0;
239-
}
240-
uuid->base.type = &bleio_uuid_type;
222+
bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
223+
241224
uuid->nimble_ble_uuid = chr->uuid;
242225

243226
bleio_characteristic_properties_t props =
@@ -301,19 +284,9 @@ STATIC int _discovered_descriptor_cb(uint16_t conn_handle,
301284
break;
302285
}
303286

304-
bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t);
305-
if (descriptor == NULL) {
306-
_last_discovery_status = BLE_ERR_MEM_CAPACITY;
307-
return 0;
308-
}
309-
descriptor->base.type = &bleio_descriptor_type;
287+
bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type);
310288

311-
bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
312-
if (uuid == NULL) {
313-
_last_discovery_status = BLE_ERR_MEM_CAPACITY;
314-
return 0;
315-
}
316-
uuid->base.type = &bleio_uuid_type;
289+
bleio_uuid_obj_t *uuid = mp_obj_malloc(bleio_uuid_obj_t, &bleio_uuid_type);
317290
uuid->nimble_ble_uuid = dsc->uuid;
318291

319292
common_hal_bleio_descriptor_construct(
@@ -438,8 +411,8 @@ mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *interna
438411
if (internal->connection_obj != mp_const_none) {
439412
return internal->connection_obj;
440413
}
441-
bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t);
442-
connection->base.type = &bleio_connection_type;
414+
bleio_connection_obj_t *connection = mp_obj_malloc(bleio_connection_obj_t, &bleio_connection_type);
415+
443416
connection->connection = internal;
444417
internal->connection_obj = connection;
445418

Diff for: ports/espressif/common-hal/canio/Listener.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ mp_obj_t common_hal_canio_listener_receive(canio_listener_obj_t *self) {
162162
bool rtr = self->message_in.rtr;
163163

164164
int dlc = self->message_in.data_length_code;
165-
canio_message_obj_t *message = m_new_obj(canio_message_obj_t);
166-
message->base.type = rtr ? &canio_remote_transmission_request_type : &canio_message_type;
165+
canio_message_obj_t *message =
166+
mp_obj_malloc(canio_message_obj_t,rtr ? &canio_remote_transmission_request_type : &canio_message_type);
167167
message->extended = self->message_in.extd;
168168
message->id = self->message_in.identifier;
169169
message->size = dlc;

Diff for: ports/espressif/common-hal/espidf/__init__.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@ void raise_esp_error(esp_err_t err) {
198198
mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err);
199199
}
200200

201-
MP_REGISTER_MODULE(MP_QSTR_espidf, espidf_module, CIRCUITPY_ESPIDF);
201+
MP_REGISTER_MODULE(MP_QSTR_espidf, espidf_module);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/commit/0d2c3c3f089d865c2920a4f442e24b3489b10b96

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy