summaryrefslogtreecommitdiffstats
path: root/strduptab.h
blob: 2bbc67ccb6ad0241c09b034743df9594a6908f75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* save memory for constant strings by keeping a list of the ones that
 * we already saw and not allocating memory for each new one.  The only
 * API is "add string and return pointer".  Will try to insert the
 * string in the table.  If the same string was already there, it will
 * return a pointer to that string, otherwise it will insert a copy of
 * the new string. */

struct stringduptable {
  size_t n,a;
  const char** s;
};

const char* strduptab_add(struct stringduptable* t,const char* s);