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

Buffer.Reserve Wrong Condition? #292

Open
SamanKia opened this issue Mar 26, 2024 · 1 comment
Open

Buffer.Reserve Wrong Condition? #292

SamanKia opened this issue Mar 26, 2024 · 1 comment

Comments

@SamanKia
Copy link

Hi.
I don't get first line in your reserve method? is this a type or I miss something?
Debug.Assert((capacity >= 0), "Invalid reserve capacity!");

/// <summary>
/// Reserve the buffer of the given capacity
/// </summary>
public void Reserve(long capacity)
{
    Debug.Assert((capacity >= 0), "Invalid reserve capacity!");
    if (capacity < 0)
        throw new ArgumentException("Invalid reserve capacity!", nameof(capacity));

    if (capacity > Capacity)
    {
        byte[] data = new byte[Math.Max(capacity, 2 * Capacity)];
        Array.Copy(_data, 0, data, 0, _size);
        _data = data;
    }
}
@chronoxor
Copy link
Owner

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