Skip to content
  • Darius Davis's avatar
    Replace all "sizeof x / sizeof x[0]" with array_length. · 779525d4
    Darius Davis authored and AndersBroman's avatar AndersBroman committed
    A "sed" script was used to replace all occurrences of "sizeof arr / sizeof
    arr[0]" (including one pair of brackets surrounding the whole expression, if
    present, and including brackets around the argument to "sizeof", if present)
    with an "array_length(x)" macro invocation.
    
    A handful of more complex cases were manually edited.
    
    The resulting code should be identical -- with the exception of a few trivial
    details such as __LINE__ values and the precise formatting of assertion
    messages.
    
    No attempt has yet been made to address expressions of the form "sizeof arr /
    sizeof (TYPE)"; These would probably require manual handling to confirm that
    the named TYPE indeed corresponds with the type of the array element.
    779525d4