Skip to content

Instantly share code, notes, and snippets.

@tarcisio-marinho
Created December 13, 2017 17:45
Show Gist options
  • Save tarcisio-marinho/0997783155a33549d54f795438f27cd7 to your computer and use it in GitHub Desktop.
Save tarcisio-marinho/0997783155a33549d54f795438f27cd7 to your computer and use it in GitHub Desktop.
get rid of a file
void *buf = malloc(BUF_SIZE); // allocate memory
memset(buf, 0, BUF_SIZE); // zero the memory
ssize_t ret = 0;
off_t shift = 0;
while((ret = write(fd, buf,
((fsize - shift >BUF_SIZE)?
BUF_SIZE:(fsize - shift)))) > 0)
shift += ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment