Skip to content

Commit 6848942

Browse files
WalterBrightdlang-bot
authored andcommitted
Improve wording of Safe Interfaces section
1 parent 29704b0 commit 6848942

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

ebook.ddoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ _=
7575

7676
_= specification boxes
7777
BEST_PRACTICE= $(P $(B Best Practices:) $0)
78-
IMPLEMENTATION_DEFINED=$(P $(B Implementation Defined): $0)
79-
UNDEFINED_BEHAVIOR=$(P $(B Undefined Behavior): $0)
78+
IMPLEMENTATION_DEFINED=$(P $(B Implementation Defined:) $0)
79+
UNDEFINED_BEHAVIOR=$(P $(B Undefined Behavior:) $0)
80+
RATIONALE=$(P $(B Rationale:) $0)
81+
NOTE=$(P $(B Note:) $0)
8082
_=

spec/function.dd

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,11 +3065,11 @@ $(H3 $(LNAME2 system-functions, System Functions))
30653065

30663066
$(H3 $(LNAME2 safe-interfaces, Safe Interfaces))
30673067

3068-
$(P Given that it is only called with $(RELATIVE_LINK2 safe-values, safe
3068+
$(P When it is only called with $(RELATIVE_LINK2 safe-values, safe
30693069
values) and $(RELATIVE_LINK2 safe-aliasing, safe aliasing), a
30703070
function has a safe interface when:)
30713071
$(OL
3072-
$(LI it cannot possibly exhibit
3072+
$(LI it cannot exhibit
30733073
$(DDSUBLINK glossary, undefined_behavior, undefined behavior),
30743074
and)
30753075
$(LI it cannot create unsafe values that are accessible from other
@@ -3104,9 +3104,9 @@ $(H3 $(LNAME2 safe-interfaces, Safe Interfaces))
31043104
---
31053105
because they iterate pointers based on unverified assumptions
31063106
(`strlen` assumes that `s` is zero-terminated; `memcpy` assumes
3107-
that `dst` and `src` are at least `nbytes` long). Any function
3107+
that the memory objects pointed to by `dst` and `src` are at least `nbytes` big). Any function
31083108
that traverses a C string passed as an argument can only be
3109-
`@system`. Any function that trusts a seperate parameter for
3109+
`@system`. Any function that trusts a separate parameter for
31103110
array bounds can only be `@system`.
31113111
)
31123112
$(LI
@@ -3118,6 +3118,7 @@ $(H3 $(LNAME2 safe-interfaces, Safe Interfaces))
31183118
either a valid pointer, which is safe, or `null` which is also
31193119
safe. It returns a pointer to a fresh allocation, so it cannot
31203120
introduce any unsafe aliasing.
3121+
$(NOTE The implementation of `malloc` is most likely @system code.)
31213122
)
31223123
$(LI
31233124
A D version of `memcpy` can have a safe interface:
@@ -3133,7 +3134,7 @@ $(H3 $(LNAME2 safe-interfaces, Safe Interfaces))
31333134
}
31343135
---
31353136
)
3136-
because the rules for safe $(RELATIVE_LINK2 safe-values, safe
3137+
because the rules for $(RELATIVE_LINK2 safe-values, safe
31373138
values) ensure that the lengths of the arrays are correct.
31383139
)
31393140
)

0 commit comments

Comments
 (0)