Skip to content

Instantly share code, notes, and snippets.

@struct
Created April 23, 2020 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save struct/8b5333ae362f258edbf17cad36a337e7 to your computer and use it in GitHub Desktop.
Save struct/8b5333ae362f258edbf17cad36a337e7 to your computer and use it in GitHub Desktop.
Open every C source and header file in a directory and replace calls to system malloc with iso_alloc
#!/bin/bash
## See https://github.com/struct/isoalloc
find . -name "*.[c|h]" | xargs sed -i -e 's/ malloc(/ iso_alloc(/g' \
-e 's/ realloc(/ iso_realloc(/g' \
-e 's/ calloc(/ iso_calloc(/g' \
-e 's/ free(/ iso_free(/g' \
-e 's/ strdup(/ iso_strdup(/g' \
-e 's/ strndup(/ iso_strndup(/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment