From: David Given Date: Thu, 12 Jan 2017 22:28:35 +0000 (+0100) Subject: Remove imap, as it was ugly and nobody used it. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=124b9f6b1e7c3e383b3211a740ab4ba15f57180f;p=ack.git Remove imap, as it was ugly and nobody used it. --- diff --git a/modules/src/data/imap.c b/modules/src/data/imap.c deleted file mode 100644 index 81982a704..000000000 --- a/modules/src/data/imap.c +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include -#include "imap.h" - -static void append(void* mapp, int left, void* right) -{ - struct imap* map = mapp; - struct imap_node* node; - - if (map->count == map->max) - { - int newmax = (map->max == 0) ? 8 : (map->max * 2); - struct imap_node* newarray = realloc(map->item, newmax * sizeof(*newarray)); - - map->max = newmax; - map->item = newarray; - } - - node = &map->item[map->count]; - map->count++; - - node->left = left; - node->right = right; -} - -void imap_put(void* mapp, int left, void* right) -{ - struct imap* map = mapp; - int i; - - for (i=0; icount; i++) - { - struct imap_node* node = &map->item[i]; - if (node->left == left) - { - node->right = right; - return; - } - } - - append(map, left, right); -} - -void imap_add(void* mapp, int left, void* right) -{ - struct imap* map = mapp; - int i; - - for (i=0; icount; i++) - { - struct imap_node* node = &map->item[i]; - if ((node->left == left) && (node->right == right)) - return; - } - - append(map, left, right); -} - -void* imap_get(void* mapp, int left) -{ - struct imap* map = mapp; - int i; - - for (i=0; icount; i++) - { - struct imap_node* node = &map->item[i]; - if (node->left == left) - return node->right; - } - - return NULL; -} - - diff --git a/modules/src/data/imap.h b/modules/src/data/imap.h deleted file mode 100644 index cb312e16c..000000000 --- a/modules/src/data/imap.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef IMAP_H -#define IMAP_H - -struct imap_node -{ - int left; - void* right; -}; - -/* Danger, Will Robinson! The type and the macro must be compatible. */ - -struct imap -{ - struct imap_node* item; - int count; - int max; -}; - -#define IMAPOF(RIGHT) \ - struct { \ - struct { int left; RIGHT* right; }* item; \ - int count; \ - int max; \ - } - -extern void imap_put(void* map, int left, void* right); -extern void imap_add(void* map, int left, void* right); -extern void* imap_get(void* map, int left); - -#endif -