  The production of heavy quarks in pp collisions provides a precision test of
perturbative QCD calculations at the LHC energies. More complex collision
systems like p--Pb collisions allow studies of cold nuclear matter effects,
such as modifications of the parton distribution functions at small x and of
the $\kt$ broadening effect. We present the ALICE results of prompt D-meson
production as a function of the charged-particle multiplicity, in pp and p--Pb
collisions at $\sqrt{s}=7$ TeV and $\sqrt{s_{NN}}=5.02$ TeV respectively. The
per-event yield of D mesons in different multiplicity and $\pt$ intervals are
compared for pp and p--Pb collisions to study the contribution of multi-parton
interactions to open-charm production. Angular correlations of prompt D mesons
and heavy-flavour decay electrons with charged hadrons in pp and p-Pb
collisions are also shown in different kinematic ranges and compared to pQCD
models. These measurements provide information on the charm fragmentation
processes, on cold nuclear matter effects on charm production, and on the
participation of charm in the collective motion arising in small collision
systems like p-Pb.
