Skip to content

Commit

Permalink
don't check malloc(0) (#6760)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Jan 23, 2025
1 parent f72e46b commit 44a87a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .ci/linters/c/alloc_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# 2. Check the next line for a check like 'if (!x || !y)'
alloc_linter = function(c_obj) {
lines = c_obj$lines
# Be a bit more precise to avoid mentions in comments
alloc_lines = grep(R"{=\s*([(]\w+\s*[*][)])?[mc]alloc[(]}", lines)
# Be a bit more precise to avoid mentions in comments, and allow
# malloc(0) to be used for convenience (e.g. #6757)
alloc_lines = grep(R"{=\s*([(]\w+\s*[*][)])?[mc]alloc[(][^0]}", lines)
if (!length(alloc_lines)) return()
# int *tmp=(int*)malloc(...); or just int tmp=malloc(...);
alloc_keys = lines[alloc_lines] |>
Expand Down

0 comments on commit 44a87a8

Please sign in to comment.