emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pam d2dd6a9796 05/16: Add functions to report free and


From: ELPA Syncer
Subject: [elpa] externals/pam d2dd6a9796 05/16: Add functions to report free and live index lists
Date: Wed, 20 Sep 2023 12:59:09 -0400 (EDT)

branch: externals/pam
commit d2dd6a9796c313e353818ab8e9543c40bc03e36e
Author: Onnie Lynn Winebarger <owinebar@gmail.com>
Commit: Onnie Lynn Winebarger <owinebar@gmail.com>

    Add functions to report free and live index lists
---
 table-allocation-manager.el | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/table-allocation-manager.el b/table-allocation-manager.el
index 6c49ba6466..c608083432 100644
--- a/table-allocation-manager.el
+++ b/table-allocation-manager.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2023  Onnie Lynn Winebarger
 
-;; Author: Onnie Lynn Winebarger <owinebar@>
+;; Author: Onnie Lynn Winebarger <owinebar@gmail.com>
 ;; Keywords: lisp, tools
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -30,6 +30,8 @@
 (eval-when-compile
   (require 'cl-lib))
 
+(require 'queue)
+
 (cl-defstruct (tam--table (:constructor tam--table-create (size))
                          (:copier tam--copy-table))
   "Table with explicitly managed allocation"
@@ -93,8 +95,9 @@
   "Get slot IDX of TBL"
   (tam--slot-contents (aref (tam--table-slots tbl) idx)))
 
-(defun tam-store (tbl obj)
-  "Store OBJ in TBL.  Returns index or nil if table is full."
+(defun tam-allocate (tbl obj)
+  "Allocate slot in TBL with contents OBJ.
+Returns index or nil if table is full."
   (let ((slot (tam--table-first-free tbl))
        idx)
     (when (not (tam-table-full tbl))
@@ -143,6 +146,24 @@ Signals an error if IDX is not in use."
     (setf (tam--slot-contents slot) nil)
     obj))
 
+(defun tam-table-free-list (tbl)
+  "Return list of free indices in TBL"
+  (let ((s (tam--table-first-free tbl))
+       (q (queue-create)))
+    (while s
+      (queue-enqueue q (tam--slot-index s))
+      (setq s (tam--slot-next s)))
+    (queue-all q)))
+
+(defun tam-table-live-list (tbl)
+  "Return list of live indices in TBL"
+  (let ((s (tam--table-first-used tbl))
+       (q (queue-create)))
+    (while s
+      (queue-enqueue q (tam--slot-index s))
+      (setq s (tam--slot-next s)))
+    (queue-all q)))
+
 
 (provide 'table-allocation-manager)
 ;;; table-allocation-manager.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]