Move zeroed globals to data? and use MAX_PATH#14
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ece43d112
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| hMain dd ? ; main window handle | ||
| hEdit dd ? ; EDIT control handle | ||
| CmdFile db MAX_PATH dup (?) ; startup file path buffer | ||
| TitleBuf db MAX_PATH dup (?) ; window title buffer |
There was a problem hiding this comment.
Reserve space for the title suffix
With CmdFile now accepting MAX_PATH-1 characters, TitleBuf being only MAX_PATH bytes is not enough for valid paths whose final component is near the NTFS/Win32 component limit. For example, opening C:\ plus a 245+ character filename fits in CmdFile, but BuildTitle copies that basename and then appends " - TinyRetroPad" without bounds, overwriting the following globals (BytesRead, fDirty, etc.). Either cap the copied basename or make the title buffer include room for the suffix.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks, this is a fair observation, but I think it is outside the intended scope of this PR.
This PR does not add new title-building behavior; BuildTitle already copied the basename into TitleBuf and appended the fixed " - TinyRetroPad" suffix without bounds. The only behavioral change here is that the path-related storage was moved into .DATA?, which lets CmdFile and TitleBuf grow from the previous 128-byte buffers to MAX_PATH without increasing initialized data size.
So this PR actually increases the available title/path buffer space compared with the existing code. Handling pathological filename lengths more rigorously would mean adding bounds checks or reserving extra suffix space, both of which are separate correctness/robustness work and would add code or storage beyond the size-reduction goal of this PR.
Given the size-first goal of TinyRetroPad, I would prefer to keep this PR limited to the storage-layout and buffer-size change rather than add new title truncation logic here.
Summary
This PR contains two small size-oriented commits:
Move zeroed globals to data?.DATAinto MASM.DATA?.CmdFile,TitleBuf, find/replace buffers, status buffer, and zero-default flags.Use MAX_PATH for file path buffer.DATA?.MAX_PATHdirectly forCmdFile,TitleBuf, command-line parsing, and Open/Save dialog path sizes.Size impact
Measured with the same local build environment for each revision:
44b7f2f).DATA?(32789fa)2ece43d)Net effect vs baseline:
Validation
build.user.battrpad.exe= 2,777 bytes