We could allocate on the stack and that wouldn't have much of a performance hit -- the issue is that it complicates the implementation quite a bit in that in order to know an appropriate size of the buffer, the file first needs an lstat and then the allocation, and then after calling readlink into the buffer we need to make sure that the name didn't change in between the lstat and the readlink call. 

For my use case I know what buffer size is appropriate at compile time since I only want to compare the link to a particular value -- in this case a link named "(overlay-whiteout)". 

I think what we could do is instead of exposing readlink and lgetxattr themselves, we could have a util function to compare the values to a string (so we'll know an appropriate buffer size directly from the string).  

Something like:
bool ReadlinkEquals(std::string const &path, std:string const &compare_value);
bool XattrEquals(std::string const &path, std::string const &attr_name, std::string const &compare_value);