mirror of
https://github.com/seregonwar/zftpd.git
synced 2026-10-22 03:32:24 -05:00
Introduce a platform allocator and scratchpad: add pal_alloc.{h,c}, pal_alloc_override.h, and pal_scratch.{h,c} (APIs and a default arena). Integrate them: add sources to the Makefile, change artifact naming and add all-platform build targets, and wire pal_scratch into main for sysctl buffer usage. Improve robustness and safety: enable FTP_LIST_SAFE_MODE in ftp_config.h, add stat-skipping and fallback behavior in directory listings, strengthen file-type checks in RETR, and harden STOR/APPE data-paths (use pool buffers, proper error handling, 64-bit counters, and logging). Fix concurrency/atomic logic in ftp_buffer_pool (use compare_exchange_strong with retry) and update ftp_session to refresh last_activity on I/O. Minor updates: mark fallback buffer as _Thread_local in pal_fileio, update docs to describe the memory strategy, bump release to 1.2.1, add tests and QA scripts, and add license headers and small metadata changes (event_loop author).
32 lines
498 B
C
32 lines
498 B
C
#include "pal_scratch.h"
|
|
#include <stdint.h>
|
|
|
|
int main(void)
|
|
{
|
|
uint8_t *p1 = NULL;
|
|
uint8_t *p2 = NULL;
|
|
|
|
if (pal_scratch_acquire(&p1, 16U) != 0) {
|
|
return 1;
|
|
}
|
|
if (p1 == NULL) {
|
|
return 2;
|
|
}
|
|
|
|
if (pal_scratch_acquire(&p2, 16U) == 0) {
|
|
return 3;
|
|
}
|
|
|
|
pal_scratch_release(p1);
|
|
|
|
if (pal_scratch_acquire(&p2, 16U) != 0) {
|
|
return 4;
|
|
}
|
|
if (p2 == NULL) {
|
|
return 5;
|
|
}
|
|
pal_scratch_release(p2);
|
|
|
|
return 0;
|
|
}
|