This functions should be used to get the maximum size for a block, not exceeding the max amount of bytes passed in argument. Thus max may be set to -1 to have no limit.