forked from Mirrors/wine-wine
widl: Add the ARRAY_SIZE() macro.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>stable
parent
fe91ae51f1
commit
bbcf44eb97
|
@ -64,7 +64,6 @@ static const struct oatype {
|
||||||
{"VARIANT", VT_VARIANT},
|
{"VARIANT", VT_VARIANT},
|
||||||
{"VARIANT_BOOL", VT_BOOL}
|
{"VARIANT_BOOL", VT_BOOL}
|
||||||
};
|
};
|
||||||
#define NTYPES (sizeof(oatypes)/sizeof(oatypes[0]))
|
|
||||||
#define KWP(p) ((const struct oatype *)(p))
|
#define KWP(p) ((const struct oatype *)(p))
|
||||||
|
|
||||||
static int kw_cmp_func(const void *s1, const void *s2)
|
static int kw_cmp_func(const void *s1, const void *s2)
|
||||||
|
@ -79,11 +78,11 @@ static unsigned short builtin_vt(const type_t *t)
|
||||||
const struct oatype *kwp;
|
const struct oatype *kwp;
|
||||||
key.kw = kw;
|
key.kw = kw;
|
||||||
#ifdef KW_BSEARCH
|
#ifdef KW_BSEARCH
|
||||||
kwp = bsearch(&key, oatypes, NTYPES, sizeof(oatypes[0]), kw_cmp_func);
|
kwp = bsearch(&key, oatypes, ARRAY_SIZE(oatypes), sizeof(oatypes[0]), kw_cmp_func);
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (kwp=NULL, i=0; i < NTYPES; i++)
|
for (kwp = NULL, i = 0; i < ARRAY_SIZE(oatypes); i++)
|
||||||
if (!kw_cmp_func(&key, &oatypes[i])) {
|
if (!kw_cmp_func(&key, &oatypes[i])) {
|
||||||
kwp = &oatypes[i];
|
kwp = &oatypes[i];
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -309,7 +309,7 @@ void add_output_to_resources( const char *type, const char *name )
|
||||||
size_t data_size = output_buffer_pos;
|
size_t data_size = output_buffer_pos;
|
||||||
size_t header_size = 5 * sizeof(unsigned int) + 2 * sizeof(unsigned short);
|
size_t header_size = 5 * sizeof(unsigned int) + 2 * sizeof(unsigned short);
|
||||||
|
|
||||||
assert( nb_resources < sizeof(resources)/sizeof(resources[0]) );
|
assert( nb_resources < ARRAY_SIZE( resources ));
|
||||||
|
|
||||||
if (type[0] != '#') header_size += (strlen( type ) + 1) * sizeof(unsigned short);
|
if (type[0] != '#') header_size += (strlen( type ) + 1) * sizeof(unsigned short);
|
||||||
else header_size += 2 * sizeof(unsigned short);
|
else header_size += 2 * sizeof(unsigned short);
|
||||||
|
|
|
@ -34,6 +34,8 @@ int strendswith(const char* str, const char* end);
|
||||||
#define __attribute__(X)
|
#define __attribute__(X)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
void parser_error(const char *s) __attribute__((noreturn));
|
void parser_error(const char *s) __attribute__((noreturn));
|
||||||
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||||
void error_loc(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
|
void error_loc(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
|
||||||
|
|
|
@ -302,7 +302,7 @@ static void set_target( const char *target )
|
||||||
|
|
||||||
if (!(p = strchr( spec, '-' ))) error( "Invalid target specification '%s'\n", target );
|
if (!(p = strchr( spec, '-' ))) error( "Invalid target specification '%s'\n", target );
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
for (i = 0; i < sizeof(cpu_names)/sizeof(cpu_names[0]); i++)
|
for (i = 0; i < ARRAY_SIZE( cpu_names ); i++)
|
||||||
{
|
{
|
||||||
if (!strcmp( cpu_names[i].name, spec ))
|
if (!strcmp( cpu_names[i].name, spec ))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue