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 23:02:45 +0200 Message-ID: <83a9vk3j7u.fsf@gnu.org> References: <83ehkz4edw.fsf@gnu.org> <83bog33wdr.fsf@gnu.org> <837gqq49j7.fsf@gnu.org> <83k3up2iem.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1350507802 19445 80.91.229.3 (17 Oct 2012 21:03:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Oct 2012 21:03:22 +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 23:03:28 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 1TOalv-0007OF-JH for ged-emacs-devel@m.gmane.org; Wed, 17 Oct 2012 23:03:23 +0200 Original-Received: from localhost ([::1]:52917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOalo-00065G-Gi for ged-emacs-devel@m.gmane.org; Wed, 17 Oct 2012 17:03:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOall-00064s-8I for emacs-devel@gnu.org; Wed, 17 Oct 2012 17:03:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOalk-0002at-6L for emacs-devel@gnu.org; Wed, 17 Oct 2012 17:03:13 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:46156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOalj-0002Z8-UX for emacs-devel@gnu.org; Wed, 17 Oct 2012 17:03:12 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MC200D002AQJ200@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Wed, 17 Oct 2012 23:02:31 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MC200CXJ2G6Z3A0@a-mtaout22.012.net.il>; Wed, 17 Oct 2012 23:02:30 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.172 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:154391 Archived-At: > From: Stefan Monnier > Cc: emacs-devel@gnu.org > Date: Wed, 17 Oct 2012 16:27:39 -0400 > > >> The code to free the C struct will be the one you write > >> specifically for it, nobody else knows how to free it. > > Then the code that GC's this new Lisp object will have to be entirely > > specific to the layout of the struct I'm using, right? > > I said "free" not "GC's". The GC decide what to free, and takes care of > freeing most of the objects in the heap. The code that frees > the Lisp_Misc file-watcher will be the generic GC code. And that > generic code will have to trigger your specific code that frees the > C struct. > > > It won't be suitable even for the similar-but-different inotify code, > > right? > > Depends, you can make it generic by having the Lisp_Misc object have > 2 slots: one containing the pointer to the C struct and another pointing > to the matching freeing function. OK, but who will call this freeing function? E.g., I don't see a call to free_misc in gc_sweep, it just puts every Lisp_Misc on the free list. Do I add the call to the freeing function in gc_sweep, similar to the call to unchain_marker for markers?