| 168 | void BMK_freeTimedFnState(BMK_timedFnState_t* state) { free(state); } |
| 169 | |
| 170 | BMK_timedFnState_t* |
| 171 | BMK_initStatic_timedFnState(void* buffer, size_t size, unsigned total_ms, unsigned run_ms) |
| 172 | { |
| 173 | typedef char check_size[ 2 * (sizeof(BMK_timedFnState_shell) >= sizeof(struct BMK_timedFnState_s)) - 1]; /* static assert : a compilation failure indicates that BMK_timedFnState_shell is not large enough */ |
| 174 | typedef struct { check_size c; BMK_timedFnState_t tfs; } tfs_align; /* force tfs to be aligned at its next best position */ |
| 175 | size_t const tfs_alignment = offsetof(tfs_align, tfs); /* provides the minimal alignment restriction for BMK_timedFnState_t */ |
| 176 | BMK_timedFnState_t* const r = (BMK_timedFnState_t*)buffer; |
| 177 | if (buffer == NULL) return NULL; |
| 178 | if (size < sizeof(struct BMK_timedFnState_s)) return NULL; |
| 179 | if ((size_t)buffer % tfs_alignment) return NULL; /* buffer must be properly aligned */ |
| 180 | BMK_resetTimedFnState(r, total_ms, run_ms); |
| 181 | return r; |
| 182 | } |
| 183 | |
| 184 | void BMK_resetTimedFnState(BMK_timedFnState_t* timedFnState, unsigned total_ms, unsigned run_ms) |
| 185 | { |
nothing calls this directly
no test coverage detected