Skip to content

Version 2#1

Merged
diderikk merged 6 commits into
mainfrom
patch/mem-improvment
Apr 18, 2026
Merged

Version 2#1
diderikk merged 6 commits into
mainfrom
patch/mem-improvment

Conversation

@diderikk

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates request/response and static-file handling from fixed-size char[] buffers (and separate buffer_size tracking) to a shared dynamic buffer struct across the server pipeline (recv → parse → load → build → send).

Changes:

  • Introduces src/data_structures/buffer.{h,c} with ENSURE_CAPACITY + dynamic allocation.
  • Updates socket recv/send, HTTP request parsing, HTTP response building, and static file reads to use buffer*.
  • Refactors session cache and worker handlers to remove the old buffer_size plumbing and rely on buffer->count.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 26 comments.

Show a summary per file
File Description
src/data_structures/buffer.h / buffer.c New dynamic buffer type and capacity growth helper
src/data_structures/session.c Session cache now stores buffer* per session (removes buffer_size_array)
src/socket.h / src/socket.c send_* and recv_* APIs updated to use buffer
src/utils/static_file.h / static_file.c Static file read now fills a buffer
src/http/request.h / request.c Request parsing now accepts a buffer*
src/http/response.h / response.c Response construction now uses buffer for body/tmp/response
src/handlers/{parser,loader,builder,sender}.c Pipeline updated to use buffer
src/listener.c Listener switched to new recv_* signatures
src/static.h / src/static.c Introduces ALLOCATE_MEMORY_ERROR; updates session return struct buffer field
CMakeLists.txt Adds and links buffer_lib
README.md Notes/ideas update

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/static_file.c Outdated
Comment thread src/utils/static_file.c Outdated
Comment thread src/handlers/loader.c Outdated
Comment thread src/static.c Outdated
Comment thread src/http/response.c Outdated
Comment thread src/handlers/sender.c Outdated
Comment thread src/socket.c
Comment thread src/socket.c
Comment thread src/data_structures/buffer.c
Comment thread src/data_structures/session.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 15 comments.

Comments suppressed due to low confidence (1)

src/static.h:16

  • REQUEST_RESPONSE_MAX_SIZE / HTML_MAX_SIZE were removed from static.h, but the repository’s unit and simulator tests still include static.h and use these macros (e.g., test/unit_tests/http/* and test/simulator/*). As-is, this PR will break the test build. Either keep these macros (possibly deprecated) or update the test code and any remaining public API to use the new buffer abstraction instead.
#include <pthread.h>

#define HTTP_HEADER_SIZE 256
#define HTTP_URI_TOKEN_COUNT 4
#define HTTP_URI_TOKEN_SIZE 200
#define HTTP_VERSION_SIZE 16
#define HTTP_METHOD_SIZE 8
#define HTTP_HEADER_SMALL_SIZE 128
#define HTTP_HEADER_ETAG_SIZE 65

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/static_file.h
Comment thread src/http/response.c
Comment thread src/http/response.c
Comment thread src/handlers/loader.c
Comment thread src/handlers/loader.c
Comment thread src/socket.c Outdated
Comment thread src/utils/static_file.c
Comment thread src/handlers/loader.c
Comment thread src/handlers/sender.c
Comment thread src/http/request.h
@diderikk diderikk merged commit 6517d6e into main Apr 18, 2026
1 check failed
Copilot stopped work on behalf of diderikk due to an error April 18, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants