all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
This commit is contained in:
24
py/malloc.c
24
py/malloc.c
@@ -87,22 +87,22 @@ void *m_malloc(size_t num_bytes) {
|
||||
if (ptr == NULL && num_bytes != 0) {
|
||||
m_malloc_fail(num_bytes);
|
||||
}
|
||||
#if MICROPY_MEM_STATS
|
||||
#if MICROPY_MEM_STATS
|
||||
MP_STATE_MEM(total_bytes_allocated) += num_bytes;
|
||||
MP_STATE_MEM(current_bytes_allocated) += num_bytes;
|
||||
UPDATE_PEAK();
|
||||
#endif
|
||||
#endif
|
||||
DEBUG_printf("malloc %d : %p\n", num_bytes, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *m_malloc_maybe(size_t num_bytes) {
|
||||
void *ptr = malloc(num_bytes);
|
||||
#if MICROPY_MEM_STATS
|
||||
#if MICROPY_MEM_STATS
|
||||
MP_STATE_MEM(total_bytes_allocated) += num_bytes;
|
||||
MP_STATE_MEM(current_bytes_allocated) += num_bytes;
|
||||
UPDATE_PEAK();
|
||||
#endif
|
||||
#endif
|
||||
DEBUG_printf("malloc %d : %p\n", num_bytes, ptr);
|
||||
return ptr;
|
||||
}
|
||||
@@ -113,11 +113,11 @@ void *m_malloc_with_finaliser(size_t num_bytes) {
|
||||
if (ptr == NULL && num_bytes != 0) {
|
||||
m_malloc_fail(num_bytes);
|
||||
}
|
||||
#if MICROPY_MEM_STATS
|
||||
#if MICROPY_MEM_STATS
|
||||
MP_STATE_MEM(total_bytes_allocated) += num_bytes;
|
||||
MP_STATE_MEM(current_bytes_allocated) += num_bytes;
|
||||
UPDATE_PEAK();
|
||||
#endif
|
||||
#endif
|
||||
DEBUG_printf("malloc %d : %p\n", num_bytes, ptr);
|
||||
return ptr;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ void *m_realloc(void *ptr, size_t new_num_bytes)
|
||||
if (new_ptr == NULL && new_num_bytes != 0) {
|
||||
m_malloc_fail(new_num_bytes);
|
||||
}
|
||||
#if MICROPY_MEM_STATS
|
||||
#if MICROPY_MEM_STATS
|
||||
// At first thought, "Total bytes allocated" should only grow,
|
||||
// after all, it's *total*. But consider for example 2K block
|
||||
// shrunk to 1K and then grown to 2K again. It's still 2K
|
||||
@@ -152,7 +152,7 @@ void *m_realloc(void *ptr, size_t new_num_bytes)
|
||||
MP_STATE_MEM(total_bytes_allocated) += diff;
|
||||
MP_STATE_MEM(current_bytes_allocated) += diff;
|
||||
UPDATE_PEAK();
|
||||
#endif
|
||||
#endif
|
||||
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
|
||||
DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
|
||||
#else
|
||||
@@ -168,7 +168,7 @@ void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move)
|
||||
#endif
|
||||
{
|
||||
void *new_ptr = realloc_ext(ptr, new_num_bytes, allow_move);
|
||||
#if MICROPY_MEM_STATS
|
||||
#if MICROPY_MEM_STATS
|
||||
// At first thought, "Total bytes allocated" should only grow,
|
||||
// after all, it's *total*. But consider for example 2K block
|
||||
// shrunk to 1K and then grown to 2K again. It's still 2K
|
||||
@@ -181,7 +181,7 @@ void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move)
|
||||
MP_STATE_MEM(current_bytes_allocated) += diff;
|
||||
UPDATE_PEAK();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
|
||||
DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
|
||||
#else
|
||||
@@ -197,9 +197,9 @@ void m_free(void *ptr)
|
||||
#endif
|
||||
{
|
||||
free(ptr);
|
||||
#if MICROPY_MEM_STATS
|
||||
#if MICROPY_MEM_STATS
|
||||
MP_STATE_MEM(current_bytes_allocated) -= num_bytes;
|
||||
#endif
|
||||
#endif
|
||||
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
|
||||
DEBUG_printf("free %p, %d\n", ptr, num_bytes);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user