mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 19:47:27 +00:00
widl: Use generic 'struct sltg_data' for collecting data.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
This commit is contained in:
parent
a1997507e8
commit
b83410936e
|
@ -39,16 +39,10 @@
|
||||||
|
|
||||||
static const GUID sltg_library_guid = { 0x204ff,0,0,{ 0xc0,0,0,0,0,0,0,0x46 } };
|
static const GUID sltg_library_guid = { 0x204ff,0,0,{ 0xc0,0,0,0,0,0,0,0x46 } };
|
||||||
|
|
||||||
struct sltg_index
|
struct sltg_data
|
||||||
{
|
{
|
||||||
int size, allocated;
|
int size, allocated;
|
||||||
char *names;
|
char *data;
|
||||||
};
|
|
||||||
|
|
||||||
struct sltg_name_table
|
|
||||||
{
|
|
||||||
int size, allocated;
|
|
||||||
char *names;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sltg_library
|
struct sltg_library
|
||||||
|
@ -74,8 +68,8 @@ struct sltg_block
|
||||||
struct sltg_typelib
|
struct sltg_typelib
|
||||||
{
|
{
|
||||||
typelib_t *typelib;
|
typelib_t *typelib;
|
||||||
struct sltg_index index;
|
struct sltg_data index;
|
||||||
struct sltg_name_table name_table;
|
struct sltg_data name_table;
|
||||||
struct sltg_library library;
|
struct sltg_library library;
|
||||||
struct sltg_block *blocks;
|
struct sltg_block *blocks;
|
||||||
int block_count;
|
int block_count;
|
||||||
|
@ -83,7 +77,14 @@ struct sltg_typelib
|
||||||
short typeinfo_count;
|
short typeinfo_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int add_index(struct sltg_index *index, const char *name)
|
static void init_sltg_data(struct sltg_data *data)
|
||||||
|
{
|
||||||
|
data->size = 0;
|
||||||
|
data->allocated = 0;
|
||||||
|
data->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int add_index(struct sltg_data *index, const char *name)
|
||||||
{
|
{
|
||||||
int name_offset = index->size;
|
int name_offset = index->size;
|
||||||
int new_size = index->size + strlen(name) + 1;
|
int new_size = index->size + strlen(name) + 1;
|
||||||
|
@ -91,27 +92,25 @@ static int add_index(struct sltg_index *index, const char *name)
|
||||||
if (new_size > index->allocated)
|
if (new_size > index->allocated)
|
||||||
{
|
{
|
||||||
index->allocated = index->allocated ? max(index->allocated * 2, new_size) : new_size;
|
index->allocated = index->allocated ? max(index->allocated * 2, new_size) : new_size;
|
||||||
index->names = xrealloc(index->names, index->allocated);
|
index->data = xrealloc(index->data, index->allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(index->names + index->size, name);
|
strcpy(index->data + index->size, name);
|
||||||
index->size = new_size;
|
index->size = new_size;
|
||||||
|
|
||||||
return name_offset;
|
return name_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_index(struct sltg_index *index)
|
static void init_index(struct sltg_data *index)
|
||||||
{
|
{
|
||||||
static const char compobj[] = { 1,'C','o','m','p','O','b','j',0 };
|
static const char compobj[] = { 1,'C','o','m','p','O','b','j',0 };
|
||||||
|
|
||||||
index->size = 0;
|
init_sltg_data(index);
|
||||||
index->allocated = 0;
|
|
||||||
index->names = NULL;
|
|
||||||
|
|
||||||
add_index(index, compobj);
|
add_index(index, compobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_name(struct sltg_name_table *name_table, const char *name)
|
static int add_name(struct sltg_data *name_table, const char *name)
|
||||||
{
|
{
|
||||||
int name_offset = name_table->size;
|
int name_offset = name_table->size;
|
||||||
int new_size = name_table->size + strlen(name) + 1 + 8;
|
int new_size = name_table->size + strlen(name) + 1 + 8;
|
||||||
|
@ -121,22 +120,20 @@ static int add_name(struct sltg_name_table *name_table, const char *name)
|
||||||
if (new_size > name_table->allocated)
|
if (new_size > name_table->allocated)
|
||||||
{
|
{
|
||||||
name_table->allocated = name_table->allocated ? max(name_table->allocated * 2, new_size) : new_size;
|
name_table->allocated = name_table->allocated ? max(name_table->allocated * 2, new_size) : new_size;
|
||||||
name_table->names = xrealloc(name_table->names, name_table->allocated);
|
name_table->data = xrealloc(name_table->data, name_table->allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(name_table->names + name_table->size, 0xff, 8);
|
memset(name_table->data + name_table->size, 0xff, 8);
|
||||||
strcpy(name_table->names + name_table->size + 8, name);
|
strcpy(name_table->data + name_table->size + 8, name);
|
||||||
name_table->size = new_size;
|
name_table->size = new_size;
|
||||||
name_table->names[name_table->size - 1] = 0; /* clear alignment */
|
name_table->data[name_table->size - 1] = 0; /* clear alignment */
|
||||||
|
|
||||||
return name_offset;
|
return name_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_name_table(struct sltg_name_table *name_table)
|
static void init_name_table(struct sltg_data *name_table)
|
||||||
{
|
{
|
||||||
name_table->size = 0;
|
init_sltg_data(name_table);
|
||||||
name_table->allocated = 0;
|
|
||||||
name_table->names = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_library(struct sltg_typelib *sltg)
|
static void init_library(struct sltg_typelib *sltg)
|
||||||
|
@ -418,7 +415,7 @@ static void sltg_write_header(struct sltg_typelib *sltg, int *library_block_star
|
||||||
entry.next = 0;
|
entry.next = 0;
|
||||||
put_data(&entry, sizeof(entry));
|
put_data(&entry, sizeof(entry));
|
||||||
|
|
||||||
put_data(sltg->index.names, sltg->index.size);
|
put_data(sltg->index.data, sltg->index.size);
|
||||||
memset(pad, 0, 9);
|
memset(pad, 0, 9);
|
||||||
put_data(pad, 9);
|
put_data(pad, 9);
|
||||||
|
|
||||||
|
@ -458,7 +455,7 @@ static void sltg_write_nametable(struct sltg_typelib *typelib)
|
||||||
memset(pad, 0xff, 0x200);
|
memset(pad, 0xff, 0x200);
|
||||||
put_data(pad, 0x200);
|
put_data(pad, 0x200);
|
||||||
put_data(&typelib->name_table.size, sizeof(typelib->name_table.size));
|
put_data(&typelib->name_table.size, sizeof(typelib->name_table.size));
|
||||||
put_data(typelib->name_table.names, typelib->name_table.size);
|
put_data(typelib->name_table.data, typelib->name_table.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sltg_write_remainder(void)
|
static void sltg_write_remainder(void)
|
||||||
|
|
Loading…
Reference in a new issue