source: abuse/tags/pd/abuse/inc/specache.hpp @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
File size: 920 bytes
Line 
1#ifndef __SPECACHE_HPP_
2#define __SPECACHE_HPP_
3
4#include "specs.hpp"
5
6
7class spec_directory_cache
8{
9  class filename_node
10  {
11    public :
12    filename_node *left,*right,*next;
13    char *fn;
14    spec_directory *sd;
15    char *filename() { return fn; }
16    filename_node(char *filename, spec_directory *dir)
17    {
18      fn=(char *)memcpy(jmalloc(strlen(filename)+1,"spec_dir cache"),filename,strlen(filename)+1);
19      sd=dir;
20      next=left=right=0;     
21    }
22    long size;
23  } *fn_root,*fn_list;
24  void clear(filename_node *f); // private recursive member 
25  long size;
26  public :
27  spec_directory *get_spec_directory(char *filename, bFILE *fp=NULL);
28  spec_directory_cache() { fn_root=0; size=0; }
29  void clear();                             // frees up all allocated memory
30  void load(bFILE *fp);
31  void save(bFILE *fp);
32  ~spec_directory_cache() { clear(); }
33} ;
34
35extern spec_directory_cache sd_cache;
36
37#endif
Note: See TracBrowser for help on using the repository browser.