| Deutsch English Français Italiano |
|
<20241210133717.db2e1230270895295813d469@example.invalid> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Emiliano <emil.g@example.invalid>
Newsgroups: comp.lang.tcl
Subject: Re: sample extension: how to beam created proc tolkens to unload
procedure
Date: Tue, 10 Dec 2024 13:37:17 -0300
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <20241210133717.db2e1230270895295813d469@example.invalid>
References: <vj921g$t4fh$1@dont-email.me>
<20241210121305.783c35bc867324876cf3ec2b@example.invalid>
<vj9p6s$t4fh$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Dec 2024 17:38:21 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2f4af88da03218da552e43d8c8f31a14";
logging-data="1107000"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5BGPMsAsgD2Xa95FNNbqKBpMQ17OUlyg="
Cancel-Lock: sha1:UrOhmNqwRycz6HhRwm7Csf8F6qw=
X-Newsreader: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
Bytes: 2890
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