Layering & ownership notes -------------------------- META_AV may or may not own av->p, depending on (av->flags & AV_FREE_P) VM does not own vm->head/tail[VM_REQ/REP] JOB does own job->vm->head/tail[VM_REQ/REP] IFACE owns its send queue and channels CHAN does not own its subprocess but does own the reply list it's receiving CONF owns its sources, interfaces and subprocesses; also the behaviour expression and the dictionary. == proc_* may not use proc->chan or call any chan_* routine; that's a layering violation. When a subprocess event occurs, the event dispatcher (main) must call proc_handle_* and then chan_handle_* if neccessary. chan_* does not deal with interfaces other than with their data members in so far as they are parameters for channels; it handles jobs directly. job_toiface, job_tochan and job_fromchan deal with channels directly. There is no real interface layer other than some parameters and a shared job queue. In other words, chan_* and job_* may freely call each other. == * meta_decode and meta_*msgtoav create new META_AVs on the heap and return them in a list. * meta_buildtree creates a copy for each META_AV on the source list, keeping its pointers but clearing AV_FREE_P. So the tree is only valid as long as the source list hasn't been freed, because that also frees the data for items that have AV_FREE_P set. It also sets the 'sub' member of the /source/ items to point to the copy it created in the destination tree. It may also create new (encapsulating) META_AVs on the heap which are present in the returned tree. * meta_encode does not free anything, nor does meta_avtomsg * meta_freeavlist *ONLY* frees the linear list and ignores the sub items. (NEW in 0.9.11) * meta_freeavtree can be used to free a whole tree. (NEW in 0.9.11)