Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILENAME_MAX is too large which waste memory#1586

Closed
chenbd opened this issue Dec 30, 2017 · 1 comment
Closed

FILENAME_MAX is too large which waste memory #1586

chenbd opened this issue Dec 30, 2017 · 1 comment

Comments

@chenbd
Copy link
Contributor

chenbd commented Dec 30, 2017

https://github.com/h2o/h2o/blob/master/include/h2o/memory.h#L136

on my system it is 4096. seems it's more than enough.

https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html

Macro: int FILENAME_MAX

The value of this macro is an integer constant expression that represents the maximum length of a file name string. It is defined in stdio.h.

Unlike PATH_MAX, this macro is defined even if there is no actual limit imposed. In such a case, its value is typically a very large number. This is always the case on GNU/Hurd systems.

Usage Note: Don’t use FILENAME_MAX as the size of an array in which to store a file name! You can’t possibly make an array that big! Use dynamic allocation (see Memory Allocation) instead.

should we make FILENAME_MAX a little smaller(eg: 256)?

@kazuho
Copy link
Member

kazuho commented Jan 5, 2018

I am fine with changing the size to 256.

Since the struct is expected to be rarely used (we use only one instance of the struct in the h2o server), I do not think that it is worth complicating the code to use dynamic allocation.

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

No branches or pull requests

2 participants