ReactOS 0.4.15-dev-7788-g1ad9096
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}
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
void pdie(const char *msg,...)
Definition: common.c:74

◆ 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}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define printf
Definition: freeldr.h:93
BOOLEAN valid
#define stdout
Definition: stdio.h:99
#define EOF
Definition: stdio.h:24
_Check_return_ _CRTIMP int __cdecl getchar(void)
Definition: file.c:3629
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define exit(n)
Definition: config.h:202

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}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

◆ 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}
struct _root root
const WCHAR * link
Definition: db.cpp:997
#define alloc
Definition: rosglue.h:13

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().