Repository: libsdl-org/SDL
File: src/haptic/windows/SDL_dinputhaptic.c (C)

Code before:
    }

    return true;

err_effectdone:
    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
    return false;
}

BOOL DIGetDirectionUpdateFlag(DIEFFECT* before, DIEFFECT* after)
{
    if (before->cAxes != after->cAxes) {
        return true;
    }
    // rglDirection must be non-null for DIEP_DIRECTION to be a valid flag
    if (after->rglDirection == NULL) {
        return false;
    }
    if (before->rglDirection == NULL) {
        return true;
    }

    return SDL_memcmp(before->rglDirection, after->rglDirection, sizeof(LONG) * before->cAxes) != 0;
}

BOOL DIGetEnvelopeUpdateFlag(DIEFFECT* before, DIEFFECT* after) {
    if (before->lpEnvelope == NULL && after->lpEnvelope == NULL) {
        return false;
    }
    // A null lpEnvelope is valid for DIEP_ENVELOPE (clears the envelope from the effect)
    if (before->lpEnvelope == NULL || after->lpEnvelope == NULL) {
        return true;
    }
    return SDL_memcmp(before->lpEnvelope, after->lpEnvelope, sizeof(DIENVELOPE)) != 0;
}

BOOL DIGetTypeSpecificParamsUpdateFlag(DIEFFECT* before, DIEFFECT* after)
{
    // Shouldn't happen since this implies an effect's type somehow changed, but need to check to avoid an out-of-bounds memcmp
    if (before->cbTypeSpecificParams != after->cbTypeSpecificParams) {
        return true;
    }
    // lpvTypeSpecificParams must be non-null for the DIEP_TYPESPECIFICPARAMS flag.
    if (after->lpvTypeSpecificParams == NULL) {
        return false;
    }
    if (before->lpvTypeSpecificParams == NULL) {
        return true;
    }
    return SDL_memcmp(before->lpvTypeSpecificParams, after->lpvTypeSpecificParams, before->cbTypeSpecificParams) != 0;
}

Review comment (suggestion):
```suggestion
BOOL DIGetEnvelopeUpdateFlag(DIEFFECT *before, DIEFFECT *after) {
```

Code after:
    }

    return true;

err_effectdone:
    SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
    return false;
}

BOOL DIGetDirectionUpdateFlag(DIEFFECT *before, DIEFFECT *after)
{
    if (before->cAxes != after->cAxes) {
        return true;
    }
    // rglDirection must be non-null for DIEP_DIRECTION to be a valid flag
    if (after->rglDirection == NULL) {
        return false;
    }
    if (before->rglDirection == NULL) {
        return true;
    }
    return SDL_memcmp(before->rglDirection, after->rglDirection, sizeof(LONG) * before->cAxes) != 0;
}

BOOL DIGetEnvelopeUpdateFlag(DIEFFECT* before, DIEFFECT* after)
{
    if (before->lpEnvelope == NULL && after->lpEnvelope == NULL) {
        return false;
    }
    // A null lpEnvelope is valid for DIEP_ENVELOPE (clears the envelope from the effect)
    if (before->lpEnvelope == NULL || after->lpEnvelope == NULL) {
        return true;
    }
    return SDL_memcmp(before->lpEnvelope, after->lpEnvelope, sizeof(DIENVELOPE)) != 0;
}

BOOL DIGetTypeSpecificParamsUpdateFlag(DIEFFECT *before, DIEFFECT *after)
{
    // Shouldn't happen since this implies an effect's type somehow changed, but need to check to avoid an out-of-bounds memcmp
    if (before->cbTypeSpecificParams != after->cbTypeSpecificParams) {
        return true;
    }
    // lpvTypeSpecificParams must be non-null for the DIEP_TYPESPECIFICPARAMS flag.
    if (after->lpvTypeSpecificParams == NULL) {
        return false;
    }
    if (before->lpvTypeSpecificParams == NULL) {
        return true;
    }
    return SDL_memcmp(before->lpvTypeSpecificParams, after->lpvTypeSpecificParams, before->cbTypeSpecificParams) != 0;
}