Part of the "beat code" is generosity, especially to a fellow traveler. In this case, Jack (Sal) gave away all his cigarettes to Gene and his boy, his hobo compatriots. This generosity extends to more than material things, such as offering someone a place to flop for the night. Or picking up hitchhikers.
Remember, it's not true generosity if you do if out of a sense of duty, or because you're trying to score karma points. It's only genuine if you do it out of love for your fellow human being, with no fear about or hope for any particular consequence.
My behaviorist friends would say that all behavior serves the function of either escaping something unpleasant or gaining something pleasant. I suppose the good feeling that comes as a result of giving to another counts as the latter, but I like to think that we can function on a higher plane and be more than rats in a maze. As Einstein said:
A man's ethical behaviour should be based effectually on sympathy, education, and social ties; no religious basis is necessary. Man would indeed be in a poor way if he had to be restrained by fear and punishment and hope of reward after death.
That is, the empathy felt by an educated person in relationship with another will yield right behaviors, such as generosity. If that's behaviorism, so be it.
We're all connected, all part of one big juicy, messy game that's much more fun when we share. Some socialist rebel who got crossways with the man a couple thousand years ago was on board with that whole sharing thing, even when it meant giving all one had. Maybe he was hip to something worthwhile.