From what I see you define n_shared to 0 above and never change it, so the variable is useless.