WIP: libc.obj: Impl allocator #338

Draft
Egor00f wants to merge 49 commits from Egor00f/kolibrios:libc.obj--add-allocator into main
Contributor

Fixed issue: #205

A small and simple implementation of an allocator instead of calling kernel syscalls that allocate memory by page.

Original PR: #311

Fixed issue: https://git.kolibrios.org/KolibriOS/kolibrios/issues/205 A small and simple implementation of an allocator instead of calling kernel syscalls that allocate memory by page. Original PR: #311
Egor00f added 2 commits 2026-02-22 08:00:42 +00:00
just add allocator instead of `_ksys_alloc`, `_ksys_free` and `_ksys_realloc`.
lib.obj: kek fix
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 1m19s
Build system / Build (pull_request) Successful in 9m45s
68c16f077e
heh kek
Egor00f requested review from mxlgv 2026-02-22 08:00:42 +00:00
Egor00f reviewed 2026-02-22 08:07:05 +00:00
@@ -10,1 +5,3 @@
return NULL;
void* ptr = malloc(num * size);
if (ptr) {
memset(ptr, 0, num * size);
Author
Contributor

Should calloc really call memset?

Should `calloc` really call `memset`?
Owner

Yes, the standard definitely guarantees that the memory allocated by calloc() is zeroed out.

Yes, the standard definitely guarantees that the memory allocated by `calloc()` is zeroed out.
mxlgv marked this conversation as resolved
Egor00f added 1 commit 2026-02-22 09:12:01 +00:00
translate comments
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 22s
Build system / Build (pull_request) Successful in 9m19s
dc0da05c55
I didn't notice that forgot
Egor00f added 1 commit 2026-02-22 09:37:46 +00:00
libc.obj: malloc_test: use fprintf(stderr, ...
Some checks failed
Build system / Build (pull_request) Failing after 3s
Build system / Check kernel codestyle (pull_request) Successful in 32s
c40ecec087
#311 (comment)
Egor00f added 1 commit 2026-02-22 09:47:34 +00:00
libc.obj: add EXIT_SUCCESS/FAILURE to stdlib.h
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 20s
Build system / Build (pull_request) Successful in 16m7s
9ce9864325
Egor00f added 1 commit 2026-02-22 10:11:21 +00:00
Merge branch 'main' into libc.obj--add-allocator
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 21s
Build system / Build (pull_request) Successful in 16m41s
fe9eb967c8
Owner

@Egor00f If you wrote this allocator yourself, you can add your authorship by analogy:

If you got this from somewhere, it’s better to keep the original copyrights

@Egor00f If you wrote this allocator yourself, you can add your authorship by analogy: https://git.kolibrios.org/KolibriOS/ports/src/commit/a797e4b21de0f4e8bfc6f6797dbfff3b71b086ce/libraries/newlib/kossup/src/posix/threads/pthread_create.c#L1 If you got this from somewhere, it’s better to keep the original copyrights
mxlgv added the C
Kind
Enhancement
Priority
Low
PR
Request changes
labels 2026-02-23 23:37:42 +00:00
mxlgv changed title from libc.obj: Add allocator to libc.obj: Impl allocator (fix #205) 2026-02-23 23:50:30 +00:00
mxlgv changed title from libc.obj: Impl allocator (fix #205) to libc.obj: Impl allocator 2026-02-24 00:02:41 +00:00
mxlgv requested changes 2026-02-24 00:02:55 +00:00
@@ -0,0 +136,4 @@
unsigned char* byte_ptr = (unsigned char*)ptr;
for (size_t i = 0; i < size; ++i) {
if (byte_ptr[i] != pattern) {
fprintf(stderr, "Error: Byte %zu does not match pattern. Expected %02X, got %02X\n",
Owner

Make sure libc.obj printf() supports %zu

Make sure libc.obj printf() supports %zu
@@ -5,3 +39,2 @@
return _ksys_alloc(size);
}
char b[32];
Owner

Unnecessary code?

Unnecessary code?
Author
Contributor

yes

yes
Egor00f added 1 commit 2026-02-25 17:23:13 +00:00
libc.obj: add authorship && other
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 1m11s
Build system / Build (pull_request) Successful in 16m49s
34e4ceef1e
Owner

@Egor00f сделай почту по приличнее если решил авторство добавить

@Egor00f сделай почту по приличнее если решил авторство добавить
Egor00f force-pushed libc.obj--add-allocator from 34e4ceef1e to 21205640b1 2026-03-05 19:00:33 +00:00 Compare
Egor00f force-pushed libc.obj--add-allocator from 21205640b1 to c015e25eac 2026-03-05 19:08:41 +00:00 Compare
Egor00f force-pushed libc.obj--add-allocator from c015e25eac to 170fa3e1b0 2026-03-05 19:54:21 +00:00 Compare
Egor00f changed title from libc.obj: Impl allocator to WIP: libc.obj: Impl allocator 2026-03-08 15:06:56 +00:00
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 20s
Required
Details
Build system / Build (pull_request) Successful in 16m59s
Required
Details
This pull request has changes conflicting with the target branch.
  • data/Tupfile.lua
  • programs/use_ob07.lua
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u libc.obj--add-allocator:Egor00f-libc.obj--add-allocator
git checkout Egor00f-libc.obj--add-allocator
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KolibriOS/kolibrios#338