From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Lisp object that refers to a C struct Date: Wed, 17 Oct 2012 18:08:54 +0200 Message-ID: <83ipa92i95.fsf@gnu.org> References: <83ehkz4edw.fsf@gnu.org> <83bog33wdr.fsf@gnu.org> <837gqq49j7.fsf@gnu.org> <83r4ox3frd.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1350490172 17706 80.91.229.3 (17 Oct 2012 16:09:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Oct 2012 16:09:32 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 17 18:09:39 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TOWBd-0000ET-0W for ged-emacs-devel@m.gmane.org; Wed, 17 Oct 2012 18:09:37 +0200 Original-Received: from localhost ([::1]:57122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOWBV-0007dj-La for ged-emacs-devel@m.gmane.org; Wed, 17 Oct 2012 12:09:29 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOWBP-0007dW-PL for emacs-devel@gnu.org; Wed, 17 Oct 2012 12:09:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOWBO-0005gf-Ge for emacs-devel@gnu.org; Wed, 17 Oct 2012 12:09:23 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:46711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOWBO-0005ga-8D for emacs-devel@gnu.org; Wed, 17 Oct 2012 12:09:22 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0MC100600OTH5N00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Wed, 17 Oct 2012 18:08:40 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MC1005WHOUFX580@a-mtaout21.012.net.il>; Wed, 17 Oct 2012 18:08:40 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.179.55.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:154384 Archived-At: > From: Stefan Monnier > Cc: emacs-devel@gnu.org > Date: Wed, 17 Oct 2012 09:34:40 -0400 > > >> What happens if someone passes you this same integer some time after > >> you've freed the C struct? > > It won't be found in the list of watches, so the command to remove > > that watch will say "Invalid watch descriptor", and Lisp-level code > > will not find the corresponding Lisp data structure. > > So the integer doesn't encode the pointer, instead it's an index into > a table of C structs. No, I have no table right now. I could add one, of course. Right now, the struct is allocated and its pointer is put into an alist as a Lisp integer, and also returned, as a Lisp integer, to the caller of the "start-watching" API. The caller is supposed to manage her watches, and pass the right integer when she wants to cancel a watch.