Ignore:
Timestamp:
Mar 13, 2025, 9:21:17 AM (2 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
3bd9508
Parents:
3483185
Message:

start proofreading string chapter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified doc/theses/mike_brooks_MMath/background.tex

    r3483185 r195f43d  
    468468\VRef[Figure]{f:ContiguousNon-contiguous} shows a powerful extension made in C99 for manipulating contiguous \vs non-contiguous arrays.\footnote{C90 also supported non-contiguous arrays.}
    469469For contiguous-array (including VLA) arguments, C99 conjoins one or more of the parameters as a downstream dimension(s), \eg @cols@, implicitly using this parameter to compute the row stride of @m@.
    470 There is now sufficient information to support subscript checking along the columns to prevent buffer-overflow problems, but subscript checking is not provided.
     470There is now sufficient information to support array copying and subscript checking along the columns to prevent changing the argument or buffer-overflow problems, but neither feature is provided.
    471471If the declaration of @fc@ is changed to:
    472472\begin{cfa}
     
    12211221This representation means that there is no real limit to how long a string can be, but programs have to scan one completely to determine its length.~\cite[p.~36]{C:old}
    12221222\end{quote}
    1223 Unfortunately, this design decision is both unsafe and inefficient.
    1224 It is common error in C to forget the storage in a character array for the terminator or overwrite the terminator, resulting in array overruns in string operations.
    1225 The need to repeatedly scan an entire string to determine its length can result in significant cost, as it is impossible to cache the length in many cases.
     1223This property is only preserved by the compiler with respect to character constants, \eg @"abc"@ is actually @"abc\0"@, \ie 4 characters rather than 3.
     1224Otherwise, the compiler does not participate, making string operations both unsafe and inefficient.
     1225For example, it is common in C to: forget that a character constant is larger than it appears during manipulation, that extra storage is needed in a character array for the terminator, or that the terminator must be preserved during string operations, otherwise there are array overruns.
     1226Finally, the need to repeatedly scan an entire string to determine its length can result in significant cost, as it is impossible to cache the length in many cases, \eg when a string is passed into another function.
    12261227
    12271228C strings are fixed size because arrays are used for the implementation.
Note: See TracChangeset for help on using the changeset viewer.