Revision bc88eb8cce00985cfbb5533e6b75e15cdecd9be5 authored by Tigran Mkrtchyan on 26 October 2017, 15:25:12 UTC, committed by Tigran Mkrtchyan on 26 October 2017, 19:22:36 UTC
Motivation:
in some workflows we have no control on how git command is executed,
however a signed tags are required.

The new config-file option tag.gpgSign enforces signed tags. Additional
command line option --no-gpg-sign is added to disable such behavior if
needed.

Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
1 parent 4e40fb3
Raw File
mru.h
#ifndef MRU_H
#define MRU_H

/**
 * A simple most-recently-used cache, backed by a doubly-linked list.
 *
 * Usage is roughly:
 *
 *   // Create a list.  Zero-initialization is required.
 *   static struct mru cache;
 *   mru_append(&cache, item);
 *   ...
 *
 *   // Iterate in MRU order.
 *   struct mru_entry *p;
 *   for (p = cache.head; p; p = p->next) {
 *	if (matches(p->item))
 *		break;
 *   }
 *
 *   // Mark an item as used, moving it to the front of the list.
 *   mru_mark(&cache, p);
 *
 *   // Reset the list to empty, cleaning up all resources.
 *   mru_clear(&cache);
 *
 * Note that you SHOULD NOT call mru_mark() and then continue traversing the
 * list; it reorders the marked item to the front of the list, and therefore
 * you will begin traversing the whole list again.
 */

struct mru_entry {
	void *item;
	struct mru_entry *prev, *next;
};

struct mru {
	struct mru_entry *head, *tail;
};

void mru_append(struct mru *mru, void *item);
void mru_mark(struct mru *mru, struct mru_entry *entry);
void mru_clear(struct mru *mru);

#endif /* MRU_H */
back to top