From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.devel Subject: Re: Universal functions to manage multiple window caches. Date: Thu, 18 Apr 2019 15:02:15 -0600 Message-ID: <878sw79gdk.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="195092"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: Emacs Devel To: Keith David Bershatsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 18 23:18:58 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hHEQo-000oYR-PS for ged-emacs-devel@m.gmane.org; Thu, 18 Apr 2019 23:18:54 +0200 Original-Received: from localhost ([127.0.0.1]:47491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEQn-0000f9-Ks for ged-emacs-devel@m.gmane.org; Thu, 18 Apr 2019 17:18:53 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEAv-0005dt-P9 for emacs-devel@gnu.org; Thu, 18 Apr 2019 17:02:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHEAu-0004Wd-Hn for emacs-devel@gnu.org; Thu, 18 Apr 2019 17:02:29 -0400 Original-Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:42328) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hHEAu-0004Ia-9W for emacs-devel@gnu.org; Thu, 18 Apr 2019 17:02:28 -0400 Original-Received: by mail-pf1-x435.google.com with SMTP id w25so1634738pfi.9 for ; Thu, 18 Apr 2019 14:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=qfVJDLp8zO7jkRCJplybw1Y2V4OWDaLVR9dYDCi+e6g=; b=klLT/EJeGI9ejCDnBBWBIxarDQ5raltm3a+fTAGyGsNhXReNwavei8bss+5aZ8HTMA TAtn+5hZE/gZKY5+g5thNtJL1gauq3rhlpON4Ja57uu8X9Fv7Of8BD2wZCGY6zbCi1aK RDL7UFumf8tJ0zOD05gOhOT5Jtz9qsaepPC9H9CQmh55OBOn/X+04CXrQBw4Ipk3Xm6o DCVEq9l+XpUDulqNU7PGguKADl4Mk5UYiFSib01TuspddArqcQa8Pgrt6IoFZ6cTkHEY xZaVpB6ofQEKYYI1ITGcKB+vPxNz0YHmecHKv5YTq7eM/Iz4x6rh3h6OqmAl4ZWxGAai gnag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=qfVJDLp8zO7jkRCJplybw1Y2V4OWDaLVR9dYDCi+e6g=; b=oc8ui/5Gu/9XzBpr4gvMeE7ArpJaxEk1ThpCXs6zT7zYajRvYYBu7Y9hQsEQ1mX/1r ISHuykwHyMW7SM2XQS6qN34Gnn5GD+DPuEtGo9qcTJkBPtD/rXUIaDQbb/qFraUgNwl1 TuZMvyV4bMrvELcnNv9r4EANlIoxwm/KaRojM08XaNjZu8WtNMzTIVkQ/ovbxr1uEeCN 4h/tnfDY0BgpumX91JJxSRkZT5p8y2USap/EyGT1J/yogR366oQ60NiqLPZBduyh3dcy G/XhHDtEHNqaNoEiVXAItPFy2m98Qc2u383qHh6d9vCHfkVRFsvF9Mz1JtsWTpvGRSfJ puLw== X-Gm-Message-State: APjAAAW6rGVCpo2wQI5ZeJkwdN9kFK6nSEz09FBiSGKkAjltlO7LOOQv KxDEXYv+ey46sUa3WH1AHRC7Ex0S X-Google-Smtp-Source: APXvYqwPLjUqrPXLz6N5d5QH3UixEySPQpBlXTBmd8rYhZ5NjyvMzqGUXqa8dmCkJ9OiblH6IZIUVw== X-Received: by 2002:a65:5003:: with SMTP id f3mr34237pgo.29.1555621333905; Thu, 18 Apr 2019 14:02:13 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id p189sm7357854pfg.184.2019.04.18.14.02.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2019 14:02:12 -0700 (PDT) In-Reply-To: (Keith David Bershatsky's message of "Wed, 17 Apr 2019 13:03:51 -0700") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::435 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:235634 Archived-At: Keith David Bershatsky writes: > I am working on feature requests 22873 (multiple fake cursors) and 17684 (crosshairs that track the cursor position). > > window.h defines four different caches of fake cursors, with the only difference between them being their names: > > struct multiple_cursors_cache *temp_elts; > ptrdiff_t temp_elts_allocated; > int temp_nelts; > > struct multiple_cursors_cache *mc_elts; > ptrdiff_t mc_elts_allocated; > int mc_nelts; > > struct multiple_cursors_cache *ch_elts; > ptrdiff_t ch_elts_allocated; > int ch_nelts; > > struct multiple_cursors_cache *fc_elts; > ptrdiff_t fc_elts_allocated; > int fc_nelts; Each of the four could just be structs themselves. Something like: struct multiple_cursor_cache { ptrdiff_t allocated; ptrdiff_t used; struct items { int x; int fx; int y; int fy; int hpos; int vpos; int wd; int h; int cursor_type; int cursor_width; struct RGB { double red; double green; double blue; } foreground, background; bool active_p; int glyph_flavor; bool enabled_p; } *caches; }; If you need to differentiate them in a helper procedure, you can add an enum element to the outermost struct. P.S. Why do you need to memset the used portion of the caches on every window update? I would think that just setting the used/*_nelts count would be sufficient as long as you make sure not to go past that and access garbage data.