ReactOS  0.4.13-dev-257-gfabbd7c
common.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void die (const char *msg,...) __attribute((noreturn
 
void format (printf, 1, 2)))
 
void pdie (const char *msg,...) __attribute((noreturn
 
voidalloc (int size)
 
voidqalloc (void **root, int size)
 
void qfree (void **root)
 
int min (int a, int b)
 
char get_key (const char *valid, const char *prompt)
 

Function Documentation

◆ alloc()

void* alloc ( int  size)

Definition at line 94 of file common.c.

95 {
96  void *this;
97 
98  if ((this = malloc(size)))
99  return this;
100  pdie("malloc");
101  return NULL; /* for GCC */
102 }
void pdie(const char *msg,...)
Definition: common.c:74
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define malloc
Definition: debug_ros.c:4

Referenced by qalloc().

◆ die()

void die ( const char msg,
  ... 
)

◆ format()

void format ( printf  ,
,
 
)

◆ get_key()

char get_key ( const char valid,
const char prompt 
)

Definition at line 184 of file common.c.

185 {
186 #ifndef __REACTOS__
187  int ch, okay;
188 
189  while (1) {
190  if (prompt)
191  printf("%s ", prompt);
192  fflush(stdout);
193  while (ch = getchar(), ch == ' ' || ch == '\t') ;
194  if (ch == EOF)
195  exit(1);
196  if (!strchr(valid, okay = ch))
197  okay = 0;
198  while (ch = getchar(), ch != '\n' && ch != EOF) ;
199  if (ch == EOF)
200  exit(1);
201  if (okay)
202  return okay;
203  printf("Invalid input.\n");
204  }
205 #else
206  return 0;
207 #endif
208 }
FILE * stdout
_Check_return_ _CRTIMP int __cdecl getchar(void)
Definition: file.c:3627
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define EOF
Definition: stdio.h:24
void exit(int exitcode)
Definition: _exit.c:33
#define printf
Definition: config.h:203

Referenced by check_backup_boot(), check_dir(), check_file(), handle_dot(), lfn_add_slot(), lfn_check_orphaned(), lfn_get(), print_fat_dirty_state(), read_fat(), read_fsinfo(), update_free(), and VfatChkdsk().

◆ min()

int min ( int  a,
int  b 
)

Definition at line 179 of file common.c.

180 {
181  return a < b ? a : b;
182 }
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by Fast486WriteMemory().

◆ pdie()

void pdie ( const char msg,
  ... 
)

◆ qalloc()

void* qalloc ( void **  root,
int  size 
)

Definition at line 139 of file common.c.

140 {
141  LINK *link;
142 
143 #ifndef __REACTOS__
144  link = alloc(sizeof(LINK));
145 #else
146  link = vfalloc(sizeof(LINK));
147 #endif
148  link->next = *root;
149  *root = link;
150 #ifndef __REACTOS__
151  return link->data = alloc(size);
152 #else
153  return link->data = vfalloc(size);
154 #endif
155 }
void * alloc(int size)
Definition: common.c:94
struct _root root
GLsizeiptr size
Definition: glext.h:5919
const WCHAR * link
Definition: db.cpp:985

Referenced by add_file(), and cnv_unicode().

◆ qfree()

void qfree ( void **  root)

Definition at line 157 of file common.c.

158 {
159  LINK *this;
160 
161  while (*root) {
162  this = (LINK *) * root;
163  *root = this->next;
164 #ifndef __REACTOS__
165  free(this->data);
166  free(this);
167 #else
168  vffree(this->data);
169  vffree(this);
170 #endif
171  }
172 }
#define free
Definition: debug_ros.c:5
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by VfatChkdsk().