The money you buy stock with l goes to the former/selling shareholder, which is most often not the company. It is possible the company is holding its own stock and selling for cash, or emitting new shares for cash, but that is much much rarer.

by 'allocated', I mean allocated during the purchase decision. not that money is sent to respective company.