File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
ports/nrf/common-hal/neopixel_write Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -150,18 +150,21 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
150
150
if (MP_STATE_VM (pixels_pattern_heap )) {
151
151
// Old pixels_pattern_heap will be gc'd; don't free it.
152
152
pixels_pattern = NULL ;
153
- MP_STATE_VM (pixels_pattern_heap ) = NULL ;
154
153
pixels_pattern_heap_size = 0 ;
155
154
}
156
155
156
+ // realloc routines fall back to a plain malloc if the incoming ptr is NULL.
157
157
if (sd_en ) {
158
158
// If the soft device is enabled then we must use PWM to
159
159
// transmit. This takes a bunch of memory to do so raise an
160
160
// exception if we can't.
161
- MP_STATE_VM (pixels_pattern_heap ) = (uint16_t * ) m_malloc (pattern_size , false);
161
+ MP_STATE_VM (pixels_pattern_heap ) =
162
+ (uint16_t * ) m_realloc (MP_STATE_VM (pixels_pattern_heap ), pattern_size );
162
163
} else {
163
164
// Might return NULL.
164
- MP_STATE_VM (pixels_pattern_heap ) = (uint16_t * ) m_malloc_maybe (pattern_size , false);
165
+ MP_STATE_VM (pixels_pattern_heap ) =
166
+ // true means move if necessary.
167
+ (uint16_t * ) m_realloc_maybe (MP_STATE_VM (pixels_pattern_heap ), pattern_size , true);
165
168
}
166
169
if (MP_STATE_VM (pixels_pattern_heap )) {
167
170
pixels_pattern_heap_size = pattern_size ;
You can’t perform that action at this time.
0 commit comments