Files
zftpd/tests/test_buffer_pool.c
T
Seregon d09bde8174 Add pal alloc/scratch, Makefile and safety fixes
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).
2026-02-17 20:02:15 +01:00

42 lines
896 B
C

#include "ftp_buffer_pool.h"
#include "ftp_config.h"
#include <stddef.h>
int main(void)
{
void *bufs[FTP_MAX_SESSIONS];
for (size_t i = 0U; i < (size_t)FTP_MAX_SESSIONS; i++) {
bufs[i] = ftp_buffer_acquire();
if (bufs[i] == NULL) {
return 1;
}
for (size_t j = 0U; j < i; j++) {
if (bufs[j] == bufs[i]) {
return 2;
}
}
}
if (ftp_buffer_acquire() != NULL) {
return 3;
}
for (size_t i = 0U; i < (size_t)FTP_MAX_SESSIONS; i++) {
ftp_buffer_release(bufs[i]);
}
for (size_t i = 0U; i < (size_t)FTP_MAX_SESSIONS; i++) {
bufs[i] = ftp_buffer_acquire();
if (bufs[i] == NULL) {
return 4;
}
}
for (size_t i = 0U; i < (size_t)FTP_MAX_SESSIONS; i++) {
ftp_buffer_release(bufs[i]);
}
return 0;
}