Re: sample extension: how to beam created proc tolkens to unload procedure

Liste des GroupesRevenir à cl tcl 
Sujet : Re: sample extension: how to beam created proc tolkens to unload procedure
De : emil.g (at) *nospam* example.invalid (Emiliano)
Groupes : comp.lang.tcl
Date : 10. Dec 2024, 17:37:17
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20241210133717.db2e1230270895295813d469@example.invalid>
References : 1 2 3
User-Agent : Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
On Tue, 10 Dec 2024 17:11:08 +0100
Harald Oehlmann <wortkarg3@yahoo.com> wrote:

Am 10.12.2024 um 16:13 schrieb Emiliano:
On Tue, 10 Dec 2024 10:35:46 +0100
Sample_Init:
struct CmdClientData *cmdClientDataPtr;
cmdClientDataPtr = ckalloc(sizeof(struct Sha1ClientData));
-------------------------------------------^
Shouldn't this be "struct CmdClientDataPtr"?
 
Yes, good catch
 
cmdClientDataPtr->sha1CmdTolken = Tcl_CreateObjCommand(
    interp, "sha1", (Tcl_ObjCmdProc *)Sha1_Cmd,
              sha1ClientDataPtr, Sha1_CmdDeleteProc);
---------------^
Shouldn't this be "cmdClientDataPtr"?
 
Well, I use a client data for the command "sha1ClientDataPtr" with the
command state, which is deleted by the command delete proc
"Sha1_CmdDeleteProc".
 
In addition, there is assoc data of the dll "cmdClientDataPtr" to keep
the command tokens for removal within the unload procedure.
 
Is this design sensible ?

Can't say without seeing the real code, but ...

* If you delete the command [sha1], either using [rename] or by deleting
  the current interpreter or namespace, you might want to unload the
  library as well, and free all allocated resources;
* If you [unload] the library, you might want to also delete the [sha1]
  command, and free all allocated resources.
* If you are using Tcl_{Get|Set}AssocData, you have to check the right
  time to use ckfree if both cleanup functions depends on clientdata
  to be valid. In this case, Tcl_Preserve/Tcl_Release and
  Tcl_EventuallyFree might be useful. Or maybe adding a flag in the
  clientdata structure to mark "This cleanup function was already been called".

 
THanks for all,
Harald

Regards
--
Emiliano

Date Sujet#  Auteur
10 Dec 24 * sample extension: how to beam created proc tolkens to unload procedure9Harald Oehlmann
10 Dec 24 `* Re: sample extension: how to beam created proc tolkens to unload procedure8Emiliano
10 Dec 24  +- Re: sample extension: how to beam created proc tolkens to unload procedure1Harald Oehlmann
10 Dec 24  +* Re: sample extension: how to beam created proc tolkens to unload procedure5Harald Oehlmann
10 Dec 24  i`* Re: sample extension: how to beam created proc tolkens to unload procedure4Emiliano
10 Dec 24  i +* Re: sample extension: how to beam created proc tolkens to unload procedure2Harald Oehlmann
10 Dec 24  i i`- Re: sample extension: how to beam created proc tolkens to unload procedure1Ralf Fassel
10 Dec 24  i `- Re: sample extension: how to beam created proc tolkens to unload procedure1Harald Oehlmann
11 Dec 24  `- Re: sample extension: how to beam created proc tolkens to unload procedure1Harald Oehlmann

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal