I imagine that the lock function could be simplified to something like:
I think that's insufficient for things that require id validation, while being overkill for things that never deallocates (and hence does *not* require id validation).
For example, the suggested code (especially `validate_lock_object`) assumes that `object->id` does not change. This doesn't hold for objects that do require id validation, since the lock/unlock can race against the server freeing (and then replacing) the object at any time.
I agree it's a good idea to consolidate object type-specific logic to the end consumer side (instead of branching on type internally), but I'm afraid the suggested code doesn't look correct as-is.