Add centrallix-lib Utilities - #130
Open
Lightning11wins wants to merge 54 commits into
Open
Lightning11wins wants to merge 54 commits into
Lightning11wins wants to merge 54 commits into
Conversation
Contributor
Greptile SummaryThis PR adds
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| centrallix-lib/src/util.c | Adds snprintBytes, snprintCommasLlu, and fprintMem utilities. fprintMem uses direct returns instead of goto error, violating the required project convention for nontrivial functions. |
| centrallix-lib/include/timer.h | Defines Timer struct and declares the timer API. The timerBenchmark debug macro uses a bare block that can cause compile errors with trailing else clauses. |
| centrallix-lib/src/timer.c | Full timer implementation with correct NaN guards for unstarted timers, accumulating stop, and clock failure handling. Previous review issues (NaN poisoning, missing null guard) are all addressed. |
| centrallix-lib/include/check.h | Error-checking macros for int, positive-int, double, and pointer results. Includes math.h and string.h for isnan/strrchr. printFail is wrapped in do-while(0). GCC statement expressions are used intentionally throughout. |
| centrallix-lib/src/mtsession.c | Refactors mssError into mssError_internal with macro wrappers, adds mssUserError, and integrates strtcpy/check utilities. The previously flagged xaAddItem leak on insertion failure has been fixed. |
| centrallix-lib/tests/test_strtcpy_11.c | Table-driven test for strtcatf() covering return values, *pos tracking, null-termination, and guard-byte integrity across normal, exact-fit, truncating, and degenerate cases. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([timerNew]) --> B[nmMalloc + timerInit\nstart=NAN, total=0]
B --> C([timerStart])
C --> D{isnan start?}
D -- Yes: not running --> E[start = getTime]
D -- No: already running --> F[noop return]
E --> G([timerStop])
G --> H{isnan start?}
H -- Yes: not started --> I[noop return]
H -- No: running --> J[stop_time = getTime]
J --> K{isnan stop_time?}
K -- Yes: clock failed --> L[keep running, return]
K -- No --> M[total += stop_time - start\nstart = NAN]
M --> N([timerGet])
N --> O{isnan start?}
O -- stopped --> P[return total]
O -- running --> Q[current = getTime - start\nreturn total + current]
P --> R([timerFree / timerReset])
Q --> R
R --> S[nmFree or re-init]
Reviews (13): Last reviewed commit: "Rename checkNeg() to checkPos()." | Re-trigger Greptile
Contributor
Author
|
This PR is ready for human review. |
Contributor
Author
|
This PR is definitely too large to be considered trivial! |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a more organized version of the utilities I created while working on #77, which have since been used in several other projects (which are now blocked by this PR).