[qfcc] Preserve input qfo data in qfo_to_progs

qfo_to_progs was modifying the space data pointers in the input qfo,
making it impossible to reuse the qfo. However, qfo_relocate_refs needs
the updated pointers, thus do a shallow copy of the qfo and its spaces
(but not any of the data)
This commit is contained in:
Bill Currie 2021-12-27 00:25:08 +09:00
parent f373192a02
commit 3059aa7979
2 changed files with 10 additions and 2 deletions

View file

@ -486,7 +486,7 @@ qfo_t *qfo_read (QFile *file);
*/
qfo_t *qfo_open (const char *filename);
dprograms_t *qfo_to_progs (qfo_t *qfo, int *size);
dprograms_t *qfo_to_progs (qfo_t *in_qfo, int *size);
pr_debug_header_t *qfo_to_sym (qfo_t *qfo, int *size);
/** Create a new ::qfo_t struct

View file

@ -919,7 +919,7 @@ qfo_def_compare (const void *i1, const void *i2, void *d)
}
dprograms_t *
qfo_to_progs (qfo_t *qfo, int *size)
qfo_to_progs (qfo_t *in_qfo, int *size)
{
byte *data;
char *strings;
@ -949,6 +949,14 @@ qfo_to_progs (qfo_t *qfo, int *size)
unsigned *far_def_indices;
unsigned *field_def_indices;
qfo_t *qfo = alloca (sizeof (qfo_t)
+ in_qfo->num_spaces * sizeof (qfo_mspace_t));
*qfo = *in_qfo;
qfo->spaces = (qfo_mspace_t *) (qfo + 1);
for (i = 0; i < qfo->num_spaces; i++) {
qfo->spaces[i] = in_qfo->spaces[i];
}
*size = RUP (sizeof (dprograms_t), 16);
progs = calloc (1, *size);
progs->version = options.code.progsversion;