Skip to content

Commit 46a3672

Browse files
committed
lib: newlib: Remove internal _sbrk lock
This commit removes the lock inside the newlib internal `_sbrk` function, which is called by `malloc` when additional heap memory is needed. This lock is no longer required because any calls to the `malloc` function are synchronised by the `__malloc_lock` and `__malloc_unlock` functions. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent fbb1bdb commit 46a3672

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

lib/libc/newlib/libc-hooks.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,10 @@ __weak void _exit(int status)
268268
}
269269
}
270270

271-
static LIBC_DATA SYS_SEM_DEFINE(heap_sem, 1, 1);
272-
273271
void *_sbrk(intptr_t count)
274272
{
275273
void *ret, *ptr;
276274

277-
/* coverity[CHECKED_RETURN] */
278-
sys_sem_take(&heap_sem, K_FOREVER);
279275
ptr = ((char *)HEAP_BASE) + heap_sz;
280276

281277
if ((heap_sz + count) < MAX_HEAP_SIZE) {
@@ -285,9 +281,6 @@ void *_sbrk(intptr_t count)
285281
ret = (void *)-1;
286282
}
287283

288-
/* coverity[CHECKED_RETURN] */
289-
sys_sem_give(&heap_sem);
290-
291284
return ret;
292285
}
293286
__weak FUNC_ALIAS(_sbrk, sbrk, void *);

0 commit comments

Comments
 (0)