/[rdesktop]/sourceforge.net/trunk/rdesktop/cache.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/cache.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 726 by stargo, Sun Jun 27 18:53:08 2004 UTC revision 775 by jsorg71, Sat Oct 2 01:01:57 2004 UTC
# Line 2  Line 2 
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Cache routines     Cache routines
4     Copyright (C) Matthew Chapman 1999-2002     Copyright (C) Matthew Chapman 1999-2002
5      
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.     (at your option) any later version.
10      
11     This program is distributed in the hope that it will be useful,     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.     GNU General Public License for more details.
15      
16     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Line 25  Line 25 
25  #define IS_PERSISTENT(id) (g_pstcache_fd[id] > 0)  #define IS_PERSISTENT(id) (g_pstcache_fd[id] > 0)
26    
27  extern int g_pstcache_fd[];  extern int g_pstcache_fd[];
28    extern BOOL g_use_rdp5;
29    
30  uint32 g_stamp;  uint32 g_stamp;
 int g_num_bitmaps_in_memory[3];  
31    
32    static int g_num_bitmaps_in_memory[3];
33    
34  /* BITMAP CACHE */  /* BITMAP CACHE */
35  static BMPCACHEENTRY g_bmpcache[3][0xa00];  static BMPCACHEENTRY g_bmpcache[3][0xa00];
36    static HBITMAP g_volatile_bc[3];
37    
38  /* Remove the least-recently used bitmap from the cache */  /* Remove the least-recently used bitmap from the cache */
39  void  void
# Line 39  cache_remove_lru_bitmap(uint8 cache_id) Line 41  cache_remove_lru_bitmap(uint8 cache_id)
41  {  {
42          int i;          int i;
43          uint16 cache_idx = 0;          uint16 cache_idx = 0;
44          uint32 m = (uint32)-1;          uint32 m = 0xffffffff;
45          BMPCACHEENTRY *pbce;          BMPCACHEENTRY *pbce;
46    
47          for (i = 0; i < NUM_ELEMENTS(g_bmpcache[cache_id]); i++)          for (i = 0; i < NUM_ELEMENTS(g_bmpcache[cache_id]); i++)
# Line 75  cache_get_bitmap(uint8 cache_id, uint16 Line 77  cache_get_bitmap(uint8 cache_id, uint16
77                          return *pbitmap;                          return *pbitmap;
78                  }                  }
79          }          }
80            else if ((cache_id < NUM_ELEMENTS(g_volatile_bc)) && (cache_idx == 0x7fff))
81            {
82                    return g_volatile_bc[cache_id];
83            }
84    
85          error("get bitmap %d:%d\n", cache_id, cache_idx);          error("get bitmap %d:%d\n", cache_id, cache_idx);
86          return NULL;          return NULL;
# Line 93  cache_put_bitmap(uint8 cache_id, uint16 Line 99  cache_put_bitmap(uint8 cache_id, uint16
99                  {                  {
100                          ui_destroy_bitmap(old);                          ui_destroy_bitmap(old);
101                  }                  }
102                  else                  else if (g_use_rdp5)
103                  {                  {
104                          if (++g_num_bitmaps_in_memory[cache_id] > BMPCACHE2_C2_CELLS)                          if (++g_num_bitmaps_in_memory[cache_id] > BMPCACHE2_C2_CELLS)
105                                  cache_remove_lru_bitmap(cache_id);                                  cache_remove_lru_bitmap(cache_id);
# Line 102  cache_put_bitmap(uint8 cache_id, uint16 Line 108  cache_put_bitmap(uint8 cache_id, uint16
108                  g_bmpcache[cache_id][cache_idx].bitmap = bitmap;                  g_bmpcache[cache_id][cache_idx].bitmap = bitmap;
109                  g_bmpcache[cache_id][cache_idx].usage = stamp;                  g_bmpcache[cache_id][cache_idx].usage = stamp;
110          }          }
111            else if ((cache_id < NUM_ELEMENTS(g_volatile_bc)) && (cache_idx == 0x7fff))
112            {
113                    old = g_volatile_bc[cache_id];
114                    if (old != NULL)
115                            ui_destroy_bitmap(old);
116                    g_volatile_bc[cache_id] = bitmap;
117            }
118          else          else
119          {          {
120                  error("put bitmap %d:%d\n", cache_id, cache_idx);                  error("put bitmap %d:%d\n", cache_id, cache_idx);

Legend:
Removed from v.726  
changed lines
  Added in v.775

  ViewVC Help
Powered by ViewVC 1.1.26