Skip to content

Conversation

@drewfer
Copy link

@drewfer drewfer commented Sep 22, 2025

This commit changes the relevant internal path buffers to use dynamic array sizing and allows Kakoune to build on GNU HURD.

  I dedicate any and all copyright interest in this software to the
  public domain.  I make this dedication for the benefit of the public at
  large and to the detriment of my heirs and successors.  I intend this
  dedication to be an overt act of relinquishment in perpetuity of all
  present and future rights to this software under copyright law.
@drewfer drewfer force-pushed the remove-max-path branch 2 times, most recently from 48e29a4 to 35143c8 Compare October 12, 2025 23:22
GNU HURD does not define the optional POSIX MAX_PATH value.
This changes all path buffers to use dynamic array sizing.
Copy link
Owner

@mawww mawww left a comment

Choose a reason for hiding this comment

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

While I did enjoy avoiding those allocations, if this breaks build on Hurd I think it makes sense to have more portable and robust code.

return mkstemp(buffer);
char* tmplt = strndup(buffer.c_str(), (size_t)buffer.length());
int fp = mkstemp(tmplt);
buffer = tmplt;
Copy link
Owner

Choose a reason for hiding this comment

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

Aren´t we leaking tmplt here ? I am not sure why we need the strndup call in the first place, you can just use mkstemp(buffer.data()) which will be a pointer to the buffer string buffer and can be mutated safely as long as the string length does not change.

StringView existing = filename;
StringView non_existing{};

using unique_cstr = std::unique_ptr<char, MallocDeleter>;
Copy link
Owner

Choose a reason for hiding this comment

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

Kakoune moved away to a custom UniquePtr implementation for compilation speed reasons, it does not support custom deleters as we did not have actual uses, but in this specific case a OnScopeEnd free{[&] { free(res); }; would probably do the trick.

void write(int fd, StringView data);
void write_to_file(StringView filename, StringView data);
int create_file(const char* filename);
int open_temp_file(StringView filename, String &tmpFile);
Copy link
Owner

Choose a reason for hiding this comment

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

we do not use camel case for parameters in kakoune, it should be tmp_file

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