ast: astAnnul now reports an error if pointer is owned by another thread

So we have *Objects* - the actual C structures, and we have *handles* -
the identifiers used by public code to refer to AST objects.

Each handle contains a pointer to a single Object, and also contains
other things (most importantly, the AST context level at which the handle
lives). A single Object can have lots of associated handles (e.g. created
by astClone). Each Object is owned ("locked") by a single thread at any
one time and the id. for the owner thread is stored in the C Object
structure itself. Likewise each handle is owned by a thread - but not
necessarily the same thread that owns the Object refered to by the handle
(the id. for the handle's owner thread is stored in the handle, not the
Object). So if several threads own different handles that point to the
same object, the only handles that can be used to access the Object are
the ones that are owned by the thread that currently has the Object
locked. An attempt to access the Object via any other handle will cause
an error to be reproted.

But astAnnul and astEnd are special cases. For instance, thread A creates
an object, clones a new pointer (i.e. handle) to it, unlocks the Object
using the new pointer and passes the new pointer to thread B. Thread B
then locks the object using the supplied pointer. From now on, only
thread B can use the object. However, it should really be possible for
thread A to annul its original pointer for the object (not the cloned
pointer but the original pointer), since doing so has no effect at all on
the object (other than to decrement its reference count), and is not
affected by any changes made to the object after it was locked by thread
B. Likewise, astEnd should be able to annul any pointers owned by the
current thread, even if the associated objects are currently locked by a
different thread.

[There are probably other similarly innocuous operations for which a
similar approach could be taken, but at the moment only astAnnul/astEnd
are treated this way.]

Previously, this sorted of worked but there was a problem. astAnnul and
astEnd correctly failed to report an error if the Object was currently
locked by another thread, but *incorrectly* also failed to report an
error if the *handle* was owned by a different thread. Consequuently,
these functions continued happily to nullify the supplied handle, leaving
the other thread (the one that actually owns the handle) in complete
confusion, resulting in a cascade of other subtle errors.

This patch fixes this, so that astAnnul/astEnd will now report an error
if an attempt is made to annul an object using a handle that is owned by
a different thread.