C and Makefile snippets

This commit is contained in:
Yannick Reiß 2024-07-26 07:42:13 +02:00
parent 94457aae68
commit e1711a1180
2 changed files with 7 additions and 1 deletions

View File

@ -105,7 +105,7 @@ snippet "(\w+) = malloc" "Automativ malloc error implementation" rA
`!p snip.rv = match.group(1)` = ($1*)malloc(sizeof(${1:int}) * $2); `!p snip.rv = match.group(1)` = ($1*)malloc(sizeof(${1:int}) * $2);
if (!`!p snip.rv = match.group(1)`) { if (!`!p snip.rv = match.group(1)`) {
/* Error */ /* Error */
(void)printf("malloc error on memory allocation of: `!p snip.rv = match.group(1)`!\n"); (void)printf("ERROR: malloc error on memory allocation of: `!p snip.rv = match.group(1)`!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
$0 $0

View File

@ -108,3 +108,9 @@ snippet rule "Add new Rule"
${1:all}: $2 ${1:all}: $2
$0 $0
endsnippet endsnippet
snippet clean "Clean the object files and binary file" b
.PHONY: clean
clean:
${1:rm *.o $(BIN)}
endsnippet