Have you considered simply deleting your personal data without touching the OS files? I assume you don't want to format because you want to give the laptop with a working OS installed. None of your personal data are in the system directories.
So, for Linux just run
sudo userdel YOUR_USER to delete your user and then
sudo rm -rf /home/YOUR_USER to delete your user's home directory. Unless the person you are giving the laptop to is both extremely curious, technically minded and has a lot of free time to mess around with your (presumably not terribly important, classified, life-and-death data) that will be enough to protect you. For windows you can do the same, just manually delete the folders you are worried about.
Finally, you can also uninstall specific programs that might contain your passwords and other data.