Quantum size effects in hafnium-oxide resistive switching