ulib uprintf to pipe not termdev, ulib Add stringbuffer and linearlist, tb Capture subshell output

This commit is contained in:
2025-10-01 20:08:44 +02:00
parent 0e4a35eb86
commit 62cf07afc7
11 changed files with 210 additions and 13 deletions

View File

@ -118,3 +118,33 @@ void ufree(void *ptr_) {
}
}
void *urealloc(void *ptr, size_t newsize) {
void *new;
UmBlock *block = (UmBlock *)(ptr - sizeof(UmBlock));
if (block->magic != BLOCK_MAGIC || block->data != ptr) {
goto err;
}
if (!ptr) {
new = umalloc(newsize);
if (!new) {
goto err;
}
} else {
if (block->size < newsize) {
new = umalloc(newsize);
if (!new) {
goto err;
}
string_memcpy(new, ptr, block->size);
ufree(ptr);
} else {
new = ptr;
}
}
return new;
err:
return NULL;
}

View File

@ -6,5 +6,6 @@
void *umalloc(size_t size);
void ufree(void *ptr_);
void *urealloc(void *ptr, size_t newsize);
#endif // ULIB_UMALLOC_UMALLOC_H_