lexical #3/19, attach and instantly remove a NULL wl_word here
this modification is faithful iff cw != NULL and cw->wl_next == NULL
cw != NULL because we have just survived an update of cw->wl_word
cw->wl_next == NULL is witnessed by:
1) cw either NULL or pointing to a wl_cons(,NULL)
2) cw not being modified, and no wl_next being modified
3) check of all function invocations with wlist/cw argument
not to modify any wl_next slot
which are:
1) cp_ccom(wlist, ...)
2) wl_free() always followed by goto nloop, which does a cw = wl_cons(,NULL)
and cp_ccom() doesn't modify any wl_next slot
the first part of the patch is intentionally similar to newword
`i' and `buf' can be modified here, because we will inevitably `goto done'
attach and instantly remove a NULL wl_word here
This commit is contained in:
parent
ddebb63425
commit
80191f3d44
|
|
@ -185,6 +185,18 @@ gotchar:
|
|||
if (i) {
|
||||
buf[i] = '\0';
|
||||
cw->wl_word = copy(buf);
|
||||
// assumption: cw != NULL and cw->wl_next == NULL
|
||||
cw->wl_next = wl_cons(NULL, NULL);
|
||||
cw->wl_next->wl_prev = cw;
|
||||
cw = cw->wl_next;
|
||||
// note: we can overwrite buf and i here
|
||||
// they won't be accessed any more (see `goto done')
|
||||
bzero(buf, NEW_BSIZE_SP);
|
||||
i = 0;
|
||||
// cw->wl_prev is the recent cw
|
||||
// thus this wl_next has been NULL per assumtion vrom above
|
||||
cw->wl_prev->wl_next = NULL;
|
||||
tfree(cw);
|
||||
} else {
|
||||
if (cw->wl_prev) {
|
||||
cw->wl_prev->wl_next = NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue