ReactOS  0.4.14-dev-583-g2a1ba2c
index.h File Reference
#include "config.h"
#include "compat.h"
Include dependency graph for index.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  frame_index
 

Macros

#define FI_NEXT(fi, framenum)   ((fi).size && framenum == (fi).next)
 

Functions

void fi_init (struct frame_index *fi)
 
void fi_exit (struct frame_index *fi)
 
int fi_resize (struct frame_index *fi, size_t newsize)
 
void fi_add (struct frame_index *fi, off_t pos)
 
int fi_set (struct frame_index *fi, off_t *offsets, off_t step, size_t fill)
 
void fi_reset (struct frame_index *fi)
 

Macro Definition Documentation

◆ FI_NEXT

#define FI_NEXT (   fi,
  framenum 
)    ((fi).size && framenum == (fi).next)

Definition at line 38 of file index.h.

Function Documentation

◆ fi_add()

void fi_add ( struct frame_index fi,
off_t  pos 
)

Definition at line 85 of file index.c.

86 {
87  debug3("wanting to add to fill %lu, step %lu, size %lu", (unsigned long)fi->fill, (unsigned long)fi->step, (unsigned long)fi->size);
88  if(fi->fill == fi->size)
89  { /* Index is full, we need to shrink... or grow. */
90  /* Store the current frame number to check later if we still want it. */
91  off_t framenum = fi->fill*fi->step;
92  /* If we want not / cannot grow, we shrink. */
93  if( !(fi->grow_size && fi_resize(fi, fi->size+fi->grow_size)==0) )
94  fi_shrink(fi);
95 
96  /* Now check if we still want to add this frame (could be that not, because of changed step). */
97  if(fi->next != framenum) return;
98  }
99  /* When we are here, we want that frame. */
100  if(fi->fill < fi->size) /* safeguard for size=1, or just generally */
101  {
102  debug1("adding to index at %p", (void*)(fi->data+fi->fill));
103  fi->data[fi->fill] = pos;
104  ++fi->fill;
105  fi->next = fi_next(fi);
106  debug3("added pos %li to index with fill %lu and step %lu", (long) pos, (unsigned long)fi->fill, (unsigned long)fi->step);
107  }
108 }
off_t next
Definition: index.h:30
__kernel_off_t off_t
Definition: linux.h:201
off_t * data
Definition: index.h:28
static void fi_shrink(struct frame_index *fi)
Definition: index.c:22
#define debug3(s, a, b, c)
Definition: debug.h:54
size_t fill
Definition: index.h:32
int fi_resize(struct frame_index *fi, size_t newsize)
Definition: index.c:57
static off_t fi_next(struct frame_index *fi)
Definition: index.c:15
size_t grow_size
Definition: index.h:33
off_t step
Definition: index.h:29
size_t size
Definition: index.h:31
#define debug1(s, a)
Definition: debug.h:52

◆ fi_exit()

void fi_exit ( struct frame_index fi)

Definition at line 49 of file index.c.

50 {
51  debug2("fi_exit: %p and %lu", (void*)fi->data, (unsigned long)fi->size);
52  if(fi->size && fi->data != NULL) free(fi->data);
53 
54  fi_init(fi); /* Be prepared for further fun, still. */
55 }
void fi_init(struct frame_index *fi)
Definition: index.c:39
#define free
Definition: debug_ros.c:5
off_t * data
Definition: index.h:28
#define debug2(s, a, b)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
size_t size
Definition: index.h:31

◆ fi_init()

void fi_init ( struct frame_index fi)

Definition at line 39 of file index.c.

40 {
41  fi->data = NULL;
42  fi->step = 1;
43  fi->fill = 0;
44  fi->size = 0;
45  fi->grow_size = 0;
46  fi->next = fi_next(fi);
47 }
off_t next
Definition: index.h:30
off_t * data
Definition: index.h:28
size_t fill
Definition: index.h:32
smooth NULL
Definition: ftsmooth.c:416
static off_t fi_next(struct frame_index *fi)
Definition: index.c:15
size_t grow_size
Definition: index.h:33
off_t step
Definition: index.h:29
size_t size
Definition: index.h:31

Referenced by fi_exit().

◆ fi_reset()

void fi_reset ( struct frame_index fi)

Definition at line 130 of file index.c.

131 {
132  debug1("reset with size %"SIZE_P, (size_p)fi->size);
133  fi->fill = 0;
134  fi->step = 1;
135  fi->next = fi_next(fi);
136 }
off_t next
Definition: index.h:30
size_t fill
Definition: index.h:32
unsigned long size_p
Definition: compat.h:138
static off_t fi_next(struct frame_index *fi)
Definition: index.c:15
#define SIZE_P
Definition: compat.h:137
off_t step
Definition: index.h:29
size_t size
Definition: index.h:31
#define debug1(s, a)
Definition: debug.h:52

◆ fi_resize()

int fi_resize ( struct frame_index fi,
size_t  newsize 
)

Definition at line 57 of file index.c.

58 {
59  off_t *newdata = NULL;
60  if(newsize == fi->size) return 0;
61 
62  if(newsize > 0 && newsize < fi->size)
63  { /* When we reduce buffer size a bit, shrink stuff. */
64  while(fi->fill > newsize){ fi_shrink(fi); }
65  }
66 
67  newdata = safe_realloc(fi->data, newsize*sizeof(off_t));
68  if(newsize == 0 || newdata != NULL)
69  {
70  fi->data = newdata;
71  fi->size = newsize;
72  if(fi->fill > fi->size) fi->fill = fi->size;
73 
74  fi->next = fi_next(fi);
75  debug2("new index of size %lu at %p", (unsigned long)fi->size, (void*)fi->data);
76  return 0;
77  }
78  else
79  {
80  error("failed to resize index!");
81  return -1;
82  }
83 }
off_t next
Definition: index.h:30
#define error(str)
Definition: mkdosfs.c:1605
__kernel_off_t off_t
Definition: linux.h:201
off_t * data
Definition: index.h:28
#define safe_realloc
Definition: intsym.h:10
static void fi_shrink(struct frame_index *fi)
Definition: index.c:22
#define debug2(s, a, b)
Definition: debug.h:53
size_t fill
Definition: index.h:32
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
static off_t fi_next(struct frame_index *fi)
Definition: index.c:15
size_t size
Definition: index.h:31

Referenced by fi_add(), and fi_set().

◆ fi_set()

int fi_set ( struct frame_index fi,
off_t offsets,
off_t  step,
size_t  fill 
)

Definition at line 110 of file index.c.

111 {
112  if(fi_resize(fi, fill) == -1) return -1;
113  fi->step = step;
114  if(offsets != NULL)
115  {
116  memcpy(fi->data, offsets, fill*sizeof(off_t));
117  fi->fill = fill;
118  }
119  else
120  {
121  /* allocation only, no entries in index yet */
122  fi->fill = 0;
123  }
124  fi->next = fi_next(fi);
125  debug3("set new index of fill %lu, size %lu at %p",
126  (unsigned long)fi->fill, (unsigned long)fi->size, (void*)fi->data);
127  return 0;
128 }
off_t next
Definition: index.h:30
__kernel_off_t off_t
Definition: linux.h:201
off_t * data
Definition: index.h:28
#define debug3(s, a, b, c)
Definition: debug.h:54
size_t fill
Definition: index.h:32
smooth NULL
Definition: ftsmooth.c:416
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int fi_resize(struct frame_index *fi, size_t newsize)
Definition: index.c:57
static off_t fi_next(struct frame_index *fi)
Definition: index.c:15
off_t step
Definition: index.h:29
size_t size
Definition: index.h:31