To keep your baby from rolling off the bed, use a diaper pin to pin their sleeper to the sheets.
I first heard this advice second-hand before I had children and, I admit, it actually sounded like a good idea at the time. But it isn't.
For one thing, it's demeaning (we restrain animals, not people) and probably uncomfortable. For another, it has the potential to be unsafe: the pin could undo and injure the baby or the baby could become entangled in the bedding (unsurprising, since it is pinned to them).
This is not an example of safe co-sleeping, although many families do find that bed-sharing increases the amount of sleep everyone gets. The benefits of co-sleeping to the breastfeeding relationship are well-documented as well.
That said, there are things to keep in mind, if like most parents, you do share your bed with your baby some or most of the time. A recent coroner's report in Ontario did a real disservice to families by ignoring the clear benefits of co-sleeping and failing outright to share some simple guidelines to keep baby safe.
It's not listed in that link, but also please don't pin the baby to the bed.