mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
The Great Renaming (prefixing with yasm_), Part 2: allocation functions.
svn path=/trunk/yasm/; revision=843
This commit is contained in:
parent
d9f68d6d4b
commit
84ee559be7
61 changed files with 651 additions and 567 deletions
|
|
@ -79,17 +79,17 @@ load_module(const char *keyword)
|
|||
}
|
||||
|
||||
/* Look for dynamic module. First build full module name from keyword. */
|
||||
name = xmalloc(5+strlen(keyword)+1);
|
||||
name = yasm_xmalloc(5+strlen(keyword)+1);
|
||||
strcpy(name, "yasm-");
|
||||
strcat(name, keyword);
|
||||
handle = lt_dlopenext(name);
|
||||
|
||||
if (!handle) {
|
||||
xfree(name);
|
||||
yasm_xfree(name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m = xmalloc(sizeof(module));
|
||||
m = yasm_xmalloc(sizeof(module));
|
||||
m->keyword = name;
|
||||
strcpy(m->keyword, keyword);
|
||||
m->handle = handle;
|
||||
|
|
@ -105,9 +105,9 @@ unload_modules(void)
|
|||
while (!SLIST_EMPTY(&modules)) {
|
||||
m = SLIST_FIRST(&modules);
|
||||
SLIST_REMOVE_HEAD(&modules, link);
|
||||
xfree(m->keyword);
|
||||
yasm_xfree(m->keyword);
|
||||
lt_dlclose(m->handle);
|
||||
xfree(m);
|
||||
yasm_xfree(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,8 +173,8 @@ main(int argc, char *argv[])
|
|||
lt_dlmalloc = malloc;
|
||||
lt_dlfree = free;
|
||||
#else
|
||||
lt_dlmalloc = xmalloc;
|
||||
lt_dlfree = xfree;
|
||||
lt_dlmalloc = yasm_xmalloc;
|
||||
lt_dlfree = yasm_xfree;
|
||||
#endif
|
||||
|
||||
/* Initialize preloaded symbol lookup table. */
|
||||
|
|
@ -219,16 +219,16 @@ main(int argc, char *argv[])
|
|||
in = fopen(in_filename, "rt");
|
||||
if (!in) {
|
||||
print_error(_("could not open file `%s'"), in_filename);
|
||||
xfree(in_filename);
|
||||
yasm_xfree(in_filename);
|
||||
if (obj_filename)
|
||||
xfree(obj_filename);
|
||||
yasm_xfree(obj_filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
/* If no files were specified or filename was "-", read stdin */
|
||||
in = stdin;
|
||||
if (!in_filename)
|
||||
in_filename = xstrdup("-");
|
||||
in_filename = yasm__xstrdup("-");
|
||||
}
|
||||
|
||||
/* Initialize line manager */
|
||||
|
|
@ -244,7 +244,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* handle preproc-only case here */
|
||||
if (preproc_only) {
|
||||
char *preproc_buf = xmalloc(PREPROC_BUF_SIZE);
|
||||
char *preproc_buf = yasm_xmalloc(PREPROC_BUF_SIZE);
|
||||
size_t got;
|
||||
|
||||
/* Default output to stdout if not specified */
|
||||
|
|
@ -254,7 +254,7 @@ main(int argc, char *argv[])
|
|||
/* Open output (object) file */
|
||||
obj = open_obj("wt");
|
||||
if (!obj) {
|
||||
xfree(preproc_buf);
|
||||
yasm_xfree(preproc_buf);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
@ -285,11 +285,11 @@ main(int argc, char *argv[])
|
|||
print_yasm_error, print_yasm_warning);
|
||||
if (obj != stdout)
|
||||
remove(obj_filename);
|
||||
xfree(preproc_buf);
|
||||
yasm_xfree(preproc_buf);
|
||||
cleanup(NULL);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
xfree(preproc_buf);
|
||||
yasm_xfree(preproc_buf);
|
||||
cleanup(NULL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ main(int argc, char *argv[])
|
|||
if (!obj_filename) {
|
||||
if (in == stdin)
|
||||
/* Default to yasm.out if no obj filename specified */
|
||||
obj_filename = xstrdup("yasm.out");
|
||||
obj_filename = yasm__xstrdup("yasm.out");
|
||||
else
|
||||
/* replace (or add) extension */
|
||||
obj_filename = replace_extension(in_filename,
|
||||
|
|
@ -521,9 +521,9 @@ cleanup(yasm_sectionhead *sections)
|
|||
|
||||
if (DO_FREE) {
|
||||
if (in_filename)
|
||||
xfree(in_filename);
|
||||
yasm_xfree(in_filename);
|
||||
if (obj_filename)
|
||||
xfree(obj_filename);
|
||||
yasm_xfree(obj_filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -536,10 +536,10 @@ not_an_option_handler(char *param)
|
|||
if (in_filename) {
|
||||
print_error(
|
||||
_("warning: can open only one input file, only the last file will be processed"));
|
||||
xfree(in_filename);
|
||||
yasm_xfree(in_filename);
|
||||
}
|
||||
|
||||
in_filename = xstrdup(param);
|
||||
in_filename = yasm__xstrdup(param);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -607,11 +607,11 @@ opt_objfile_handler(/*@unused@*/ char *cmd, char *param,
|
|||
if (obj_filename) {
|
||||
print_error(
|
||||
_("warning: can output to only one object file, last specified used"));
|
||||
xfree(obj_filename);
|
||||
yasm_xfree(obj_filename);
|
||||
}
|
||||
|
||||
assert(param != NULL);
|
||||
obj_filename = xstrdup(param);
|
||||
obj_filename = yasm__xstrdup(param);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -673,7 +673,7 @@ replace_extension(const char *orig, /*@null@*/ const char *ext,
|
|||
char *out, *outext;
|
||||
|
||||
/* allocate enough space for full existing name + extension */
|
||||
out = xmalloc(strlen(orig)+(ext ? (strlen(ext)+2) : 1));
|
||||
out = yasm_xmalloc(strlen(orig)+(ext ? (strlen(ext)+2) : 1));
|
||||
strcpy(out, orig);
|
||||
outext = strrchr(out, '.');
|
||||
if (outext) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ yasm_arch_common_initialize(yasm_arch *a)
|
|||
yasm_insn_operand *
|
||||
yasm_operand_new_reg(unsigned long reg)
|
||||
{
|
||||
yasm_insn_operand *retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
|
||||
retval->type = YASM_INSN__OPERAND_REG;
|
||||
retval->data.reg = reg;
|
||||
|
|
@ -58,7 +58,7 @@ yasm_operand_new_reg(unsigned long reg)
|
|||
yasm_insn_operand *
|
||||
yasm_operand_new_segreg(unsigned long segreg)
|
||||
{
|
||||
yasm_insn_operand *retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
|
||||
retval->type = YASM_INSN__OPERAND_SEGREG;
|
||||
retval->data.reg = segreg;
|
||||
|
|
@ -71,7 +71,7 @@ yasm_operand_new_segreg(unsigned long segreg)
|
|||
yasm_insn_operand *
|
||||
yasm_operand_new_mem(/*@only@*/ yasm_effaddr *ea)
|
||||
{
|
||||
yasm_insn_operand *retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
|
||||
retval->type = YASM_INSN__OPERAND_MEMORY;
|
||||
retval->data.ea = ea;
|
||||
|
|
@ -92,7 +92,7 @@ yasm_operand_new_imm(/*@only@*/ yasm_expr *val)
|
|||
retval = yasm_operand_new_reg(*reg);
|
||||
yasm_expr_delete(val);
|
||||
} else {
|
||||
retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
retval->type = YASM_INSN__OPERAND_IMM;
|
||||
retval->data.val = val;
|
||||
retval->targetmod = 0;
|
||||
|
|
@ -149,7 +149,7 @@ yasm_ops_delete(yasm_insn_operandhead *headp, int content)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
xfree(cur);
|
||||
yasm_xfree(cur);
|
||||
cur = next;
|
||||
}
|
||||
STAILQ_INIT(headp);
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ ErrCode BitVector_Boot(void)
|
|||
FACTOR = LOGBITS - 3; /* ld(BITS / 8) = ld(BITS) - ld(8) = ld(BITS) - 3 */
|
||||
MSB = (LSB << MODMASK);
|
||||
|
||||
BITMASKTAB = (wordptr) xmalloc((size_t) (BITS << FACTOR));
|
||||
BITMASKTAB = (wordptr) yasm_xmalloc((size_t) (BITS << FACTOR));
|
||||
|
||||
if (BITMASKTAB == NULL) return(ErrCode_Null);
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ ErrCode BitVector_Boot(void)
|
|||
|
||||
void BitVector_Shutdown(void)
|
||||
{
|
||||
if (BITMASKTAB) xfree(BITMASKTAB);
|
||||
if (BITMASKTAB) yasm_xfree(BITMASKTAB);
|
||||
}
|
||||
|
||||
N_word BitVector_Size(N_int bits) /* bit vector size (# of words) */
|
||||
|
|
@ -399,7 +399,7 @@ N_int BitVector_Long_Bits(void)
|
|||
|
||||
void BitVector_Dispose(charptr string) /* free string */
|
||||
{
|
||||
if (string != NULL) xfree((voidptr) string);
|
||||
if (string != NULL) yasm_xfree((voidptr) string);
|
||||
}
|
||||
|
||||
void BitVector_Destroy(wordptr addr) /* free bitvec */
|
||||
|
|
@ -407,7 +407,7 @@ void BitVector_Destroy(wordptr addr) /* free bitvec */
|
|||
if (addr != NULL)
|
||||
{
|
||||
addr -= BIT_VECTOR_HIDDEN_WORDS;
|
||||
xfree((voidptr) addr);
|
||||
yasm_xfree((voidptr) addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ wordptr BitVector_Create(N_int bits, boolean clear) /* malloc */
|
|||
size = BitVector_Size(bits);
|
||||
mask = BitVector_Mask(bits);
|
||||
bytes = (size + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
|
||||
addr = (wordptr) xmalloc((size_t) bytes);
|
||||
addr = (wordptr) yasm_xmalloc((size_t) bytes);
|
||||
if (addr != NULL)
|
||||
{
|
||||
*addr++ = bits;
|
||||
|
|
@ -507,7 +507,7 @@ wordptr BitVector_Resize(wordptr oldaddr, N_int bits) /* realloc */
|
|||
else
|
||||
{
|
||||
bytes = (newsize + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
|
||||
newaddr = (wordptr) xmalloc((size_t) bytes);
|
||||
newaddr = (wordptr) yasm_xmalloc((size_t) bytes);
|
||||
if (newaddr != NULL)
|
||||
{
|
||||
*newaddr++ = bits;
|
||||
|
|
@ -1428,7 +1428,7 @@ charptr BitVector_to_Hex(wordptr addr)
|
|||
|
||||
length = bits >> 2;
|
||||
if (bits AND 0x0003) length++;
|
||||
string = (charptr) xmalloc((size_t) (length+1));
|
||||
string = (charptr) yasm_xmalloc((size_t) (length+1));
|
||||
if (string == NULL) return(NULL);
|
||||
string += length;
|
||||
*string = (N_char) '\0';
|
||||
|
|
@ -1540,7 +1540,7 @@ charptr BitVector_to_Bin(wordptr addr)
|
|||
charptr string;
|
||||
|
||||
length = bits_(addr);
|
||||
string = (charptr) xmalloc((size_t) (length+1));
|
||||
string = (charptr) yasm_xmalloc((size_t) (length+1));
|
||||
if (string == NULL) return(NULL);
|
||||
string += length;
|
||||
*string = (N_char) '\0';
|
||||
|
|
@ -1623,7 +1623,7 @@ charptr BitVector_to_Dec(wordptr addr)
|
|||
|
||||
length = (N_word) (bits / 3.3); /* digits = bits * ln(2) / ln(10) */
|
||||
length += 2; /* compensate for truncating & provide space for minus sign */
|
||||
result = (charptr) xmalloc((size_t) (length+1)); /* remember the '\0'! */
|
||||
result = (charptr) yasm_xmalloc((size_t) (length+1)); /* remember the '\0'! */
|
||||
if (result == NULL) return(NULL);
|
||||
string = result;
|
||||
sign = BitVector_Sign(addr);
|
||||
|
|
@ -2064,7 +2064,7 @@ charptr BitVector_to_Enum(wordptr addr)
|
|||
}
|
||||
}
|
||||
else length = 1;
|
||||
string = (charptr) xmalloc((size_t) length);
|
||||
string = (charptr) yasm_xmalloc((size_t) length);
|
||||
if (string == NULL) return(NULL);
|
||||
start = 0;
|
||||
comma = FALSE;
|
||||
|
|
@ -3247,7 +3247,7 @@ charptr BitVector_Block_Read(wordptr addr, N_intptr length)
|
|||
|
||||
/* provide translation for independence of endian-ness: */
|
||||
*length = size << FACTOR;
|
||||
buffer = (charptr) xmalloc((size_t) ((*length)+1));
|
||||
buffer = (charptr) yasm_xmalloc((size_t) ((*length)+1));
|
||||
if (buffer == NULL) return(NULL);
|
||||
target = buffer;
|
||||
if (size > 0)
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ yasm_imm_new_int(unsigned long int_val, unsigned long lindex)
|
|||
yasm_immval *
|
||||
yasm_imm_new_expr(yasm_expr *expr_ptr)
|
||||
{
|
||||
yasm_immval *im = xmalloc(sizeof(yasm_immval));
|
||||
yasm_immval *im = yasm_xmalloc(sizeof(yasm_immval));
|
||||
|
||||
im->val = expr_ptr;
|
||||
im->len = 0;
|
||||
|
|
@ -164,7 +164,7 @@ yasm_ea_delete(yasm_effaddr *ea)
|
|||
if (cur_arch->ea_data_delete)
|
||||
cur_arch->ea_data_delete(ea);
|
||||
yasm_expr_delete(ea->disp);
|
||||
xfree(ea);
|
||||
yasm_xfree(ea);
|
||||
}
|
||||
/*@=nullstate@*/
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ yasm_bc_set_multiple(yasm_bytecode *bc, yasm_expr *e)
|
|||
yasm_bytecode *
|
||||
yasm_bc_new_common(yasm_bytecode_type type, size_t size, unsigned long lindex)
|
||||
{
|
||||
yasm_bytecode *bc = xmalloc(size);
|
||||
yasm_bytecode *bc = yasm_xmalloc(size);
|
||||
|
||||
bc->type = type;
|
||||
|
||||
|
|
@ -323,7 +323,7 @@ yasm_bc_delete(yasm_bytecode *bc)
|
|||
break;
|
||||
case YASM_BC__INCBIN:
|
||||
incbin = (bytecode_incbin *)bc;
|
||||
xfree(incbin->filename);
|
||||
yasm_xfree(incbin->filename);
|
||||
yasm_expr_delete(incbin->start);
|
||||
yasm_expr_delete(incbin->maxlen);
|
||||
break;
|
||||
|
|
@ -348,7 +348,7 @@ yasm_bc_delete(yasm_bytecode *bc)
|
|||
/*@=branchstate@*/
|
||||
|
||||
yasm_expr_delete(bc->multiple);
|
||||
xfree(bc);
|
||||
yasm_xfree(bc);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -799,7 +799,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
*gap = 0;
|
||||
|
||||
if (*bufsize < datasize) {
|
||||
mybuf = xmalloc(sizeof(bc->len));
|
||||
mybuf = yasm_xmalloc(sizeof(bc->len));
|
||||
origbuf = mybuf;
|
||||
destbuf = mybuf;
|
||||
} else {
|
||||
|
|
@ -874,7 +874,7 @@ yasm_bcs_append(yasm_bytecodehead *headp, yasm_bytecode *bc)
|
|||
STAILQ_INSERT_TAIL(headp, bc, link);
|
||||
return bc;
|
||||
} else {
|
||||
xfree(bc);
|
||||
yasm_xfree(bc);
|
||||
}
|
||||
}
|
||||
return (yasm_bytecode *)NULL;
|
||||
|
|
@ -908,7 +908,7 @@ yasm_bcs_traverse(yasm_bytecodehead *headp, void *d,
|
|||
yasm_dataval *
|
||||
yasm_dv_new_expr(yasm_expr *expn)
|
||||
{
|
||||
yasm_dataval *retval = xmalloc(sizeof(yasm_dataval));
|
||||
yasm_dataval *retval = yasm_xmalloc(sizeof(yasm_dataval));
|
||||
|
||||
retval->type = DV_EXPR;
|
||||
retval->data.expn = expn;
|
||||
|
|
@ -919,7 +919,7 @@ yasm_dv_new_expr(yasm_expr *expn)
|
|||
yasm_dataval *
|
||||
yasm_dv_new_string(char *str_val)
|
||||
{
|
||||
yasm_dataval *retval = xmalloc(sizeof(yasm_dataval));
|
||||
yasm_dataval *retval = yasm_xmalloc(sizeof(yasm_dataval));
|
||||
|
||||
retval->type = DV_STRING;
|
||||
retval->data.str_val = str_val;
|
||||
|
|
@ -940,12 +940,12 @@ yasm_dvs_delete(yasm_datavalhead *headp)
|
|||
yasm_expr_delete(cur->data.expn);
|
||||
break;
|
||||
case DV_STRING:
|
||||
xfree(cur->data.str_val);
|
||||
yasm_xfree(cur->data.str_val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xfree(cur);
|
||||
yasm_xfree(cur);
|
||||
cur = next;
|
||||
}
|
||||
STAILQ_INIT(headp);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ yasm_errwarn_cleanup(void)
|
|||
we = SLIST_FIRST(&errwarns);
|
||||
|
||||
SLIST_REMOVE_HEAD(&errwarns, link);
|
||||
xfree(we);
|
||||
yasm_xfree(we);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
|
|||
we = ins_we;
|
||||
} else {
|
||||
/* add a new error */
|
||||
we = xmalloc(sizeof(errwarn_data));
|
||||
we = yasm_xmalloc(sizeof(errwarn_data));
|
||||
|
||||
we->type = WE_UNKNOWN;
|
||||
we->line = lindex;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
unsigned long lindex)
|
||||
{
|
||||
yasm_expr *ptr, *sube;
|
||||
ptr = xmalloc(sizeof(yasm_expr));
|
||||
ptr = yasm_xmalloc(sizeof(yasm_expr));
|
||||
|
||||
ptr->op = op;
|
||||
ptr->numterms = 0;
|
||||
|
|
@ -73,7 +73,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
ptr->terms[1].type = YASM_EXPR_NONE;
|
||||
if (left) {
|
||||
ptr->terms[0] = *left; /* structure copy */
|
||||
xfree(left);
|
||||
yasm_xfree(left);
|
||||
ptr->numterms++;
|
||||
|
||||
/* Search downward until we find something *other* than an
|
||||
|
|
@ -84,7 +84,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
sube = ptr->terms[0].data.expn;
|
||||
ptr->terms[0] = sube->terms[0]; /* structure copy */
|
||||
/*@-usereleased@*/
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
} else {
|
||||
|
|
@ -93,7 +93,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
|
||||
if (right) {
|
||||
ptr->terms[1] = *right; /* structure copy */
|
||||
xfree(right);
|
||||
yasm_xfree(right);
|
||||
ptr->numterms++;
|
||||
|
||||
/* Search downward until we find something *other* than an
|
||||
|
|
@ -104,7 +104,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
sube = ptr->terms[1].data.expn;
|
||||
ptr->terms[1] = sube->terms[0]; /* structure copy */
|
||||
/*@-usereleased@*/
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
yasm_expr__item *
|
||||
yasm_expr_sym(yasm_symrec *s)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_SYM;
|
||||
e->data.sym = s;
|
||||
return e;
|
||||
|
|
@ -128,7 +128,7 @@ yasm_expr_sym(yasm_symrec *s)
|
|||
yasm_expr__item *
|
||||
yasm_expr_expr(yasm_expr *x)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_EXPR;
|
||||
e->data.expn = x;
|
||||
return e;
|
||||
|
|
@ -137,7 +137,7 @@ yasm_expr_expr(yasm_expr *x)
|
|||
yasm_expr__item *
|
||||
yasm_expr_int(yasm_intnum *i)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_INT;
|
||||
e->data.intn = i;
|
||||
return e;
|
||||
|
|
@ -146,7 +146,7 @@ yasm_expr_int(yasm_intnum *i)
|
|||
yasm_expr__item *
|
||||
yasm_expr_float(yasm_floatnum *f)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_FLOAT;
|
||||
e->data.flt = f;
|
||||
return e;
|
||||
|
|
@ -155,7 +155,7 @@ yasm_expr_float(yasm_floatnum *f)
|
|||
yasm_expr__item *
|
||||
yasm_expr_reg(unsigned long reg)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_REG;
|
||||
e->data.reg = reg;
|
||||
return e;
|
||||
|
|
@ -254,8 +254,8 @@ expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e,
|
|||
}
|
||||
if (e->numterms != numterms) {
|
||||
e->numterms = numterms;
|
||||
e = xrealloc(e, sizeof(yasm_expr)+((numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(numterms-2)));
|
||||
e = yasm_xrealloc(e, sizeof(yasm_expr)+((numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(numterms-2)));
|
||||
if (numterms == 1)
|
||||
e->op = YASM_EXPR_IDENT;
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e,
|
|||
static void
|
||||
expr_xform_neg_item(yasm_expr *e, yasm_expr__item *ei)
|
||||
{
|
||||
yasm_expr *sube = xmalloc(sizeof(yasm_expr));
|
||||
yasm_expr *sube = yasm_xmalloc(sizeof(yasm_expr));
|
||||
|
||||
/* Build -1*ei subexpression */
|
||||
sube->op = YASM_EXPR_MUL;
|
||||
|
|
@ -339,7 +339,7 @@ expr_xform_neg_helper(/*@returned@*/ /*@only@*/ yasm_expr *e)
|
|||
/* Everything else. MUL will be combined when it's leveled.
|
||||
* Make a new expr (to replace e) with -1*e.
|
||||
*/
|
||||
ne = xmalloc(sizeof(yasm_expr));
|
||||
ne = yasm_xmalloc(sizeof(yasm_expr));
|
||||
ne->op = YASM_EXPR_MUL;
|
||||
ne->line = e->line;
|
||||
ne->numterms = 2;
|
||||
|
|
@ -514,7 +514,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
*/
|
||||
while (e->op == YASM_EXPR_IDENT && e->terms[0].type == YASM_EXPR_EXPR) {
|
||||
yasm_expr *sube = e->terms[0].data.expn;
|
||||
xfree(e);
|
||||
yasm_xfree(e);
|
||||
e = sube;
|
||||
}
|
||||
level_numterms = e->numterms;
|
||||
|
|
@ -527,7 +527,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
e->terms[i].data.expn->op == YASM_EXPR_IDENT) {
|
||||
yasm_expr *sube = e->terms[i].data.expn;
|
||||
e->terms[i] = sube->terms[0];
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
}
|
||||
|
||||
if (e->terms[i].type == YASM_EXPR_EXPR &&
|
||||
|
|
@ -592,8 +592,8 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
level_numterms <= fold_numterms) {
|
||||
/* Downsize e if necessary */
|
||||
if (fold_numterms < e->numterms && e->numterms > 2)
|
||||
e = xrealloc(e, sizeof(yasm_expr)+((fold_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(fold_numterms-2)));
|
||||
e = yasm_xrealloc(e, sizeof(yasm_expr)+((fold_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(fold_numterms-2)));
|
||||
/* Update numterms */
|
||||
e->numterms = fold_numterms;
|
||||
return e;
|
||||
|
|
@ -609,8 +609,8 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
}
|
||||
|
||||
/* Alloc more (or conceivably less, but not usually) space for e */
|
||||
e = xrealloc(e, sizeof(yasm_expr)+((level_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(level_numterms-2)));
|
||||
e = yasm_xrealloc(e, sizeof(yasm_expr)+((level_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(level_numterms-2)));
|
||||
|
||||
/* Copy up ExprItem's. Iterate from right to left to keep the same
|
||||
* ordering as was present originally.
|
||||
|
|
@ -647,7 +647,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
/* delete subexpression, but *don't delete nodes* (as we've just
|
||||
* copied them!)
|
||||
*/
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
} else if (o != i) {
|
||||
/* copy operand if it changed places */
|
||||
if (o == first_int_term)
|
||||
|
|
@ -804,8 +804,8 @@ yasm_expr__copy_except(const yasm_expr *e, int except)
|
|||
yasm_expr *n;
|
||||
int i;
|
||||
|
||||
n = xmalloc(sizeof(yasm_expr) +
|
||||
sizeof(yasm_expr__item)*(e->numterms<2?0:e->numterms-2));
|
||||
n = yasm_xmalloc(sizeof(yasm_expr) +
|
||||
sizeof(yasm_expr__item)*(e->numterms<2?0:e->numterms-2));
|
||||
|
||||
n->op = e->op;
|
||||
n->line = e->line;
|
||||
|
|
@ -865,7 +865,7 @@ expr_delete_each(/*@only@*/ yasm_expr *e, /*@unused@*/ void *d)
|
|||
break; /* none of the other types needs to be deleted */
|
||||
}
|
||||
}
|
||||
xfree(e); /* free ourselves */
|
||||
yasm_xfree(e); /* free ourselves */
|
||||
return 0; /* don't stop recursion */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,8 +166,8 @@ yasm_floatnum_initialize(void)
|
|||
int i;
|
||||
|
||||
/* Allocate space for two POT tables */
|
||||
POT_TableN = xmalloc(14*sizeof(POT_Entry));
|
||||
POT_TableP = xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
|
||||
POT_TableN = yasm_xmalloc(14*sizeof(POT_Entry));
|
||||
POT_TableP = yasm_xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
|
||||
|
||||
/* Initialize entry[0..12] */
|
||||
for (i=12; i>=0; i--) {
|
||||
|
|
@ -203,8 +203,8 @@ yasm_floatnum_cleanup(void)
|
|||
}
|
||||
BitVector_Destroy(POT_TableP[14].f.mantissa);
|
||||
|
||||
xfree(POT_TableN);
|
||||
xfree(POT_TableP);
|
||||
yasm_xfree(POT_TableN);
|
||||
yasm_xfree(POT_TableP);
|
||||
}
|
||||
/*@=globstate@*/
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ yasm_floatnum_new(const char *str)
|
|||
int decimal_pt;
|
||||
boolean carry;
|
||||
|
||||
flt = xmalloc(sizeof(yasm_floatnum));
|
||||
flt = yasm_xmalloc(sizeof(yasm_floatnum));
|
||||
|
||||
flt->mantissa = BitVector_Create(MANT_BITS, TRUE);
|
||||
|
||||
|
|
@ -490,7 +490,7 @@ yasm_floatnum_new(const char *str)
|
|||
yasm_floatnum *
|
||||
yasm_floatnum_copy(const yasm_floatnum *flt)
|
||||
{
|
||||
yasm_floatnum *f = xmalloc(sizeof(yasm_floatnum));
|
||||
yasm_floatnum *f = yasm_xmalloc(sizeof(yasm_floatnum));
|
||||
|
||||
f->mantissa = BitVector_Clone(flt->mantissa);
|
||||
f->exponent = flt->exponent;
|
||||
|
|
@ -504,7 +504,7 @@ void
|
|||
yasm_floatnum_delete(yasm_floatnum *flt)
|
||||
{
|
||||
BitVector_Destroy(flt->mantissa);
|
||||
xfree(flt);
|
||||
yasm_xfree(flt);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -618,7 +618,7 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr,
|
|||
memcpy(ptr, buf, byte_size*sizeof(unsigned char));
|
||||
|
||||
/* free allocated resources */
|
||||
xfree(buf);
|
||||
yasm_xfree(buf);
|
||||
|
||||
BitVector_Destroy(output);
|
||||
|
||||
|
|
@ -698,7 +698,7 @@ yasm_floatnum_print(FILE *f, const yasm_floatnum *flt)
|
|||
str = BitVector_to_Hex(flt->mantissa);
|
||||
fprintf(f, "%c %s *2^%04x\n", flt->sign?'-':'+', (char *)str,
|
||||
flt->exponent);
|
||||
xfree(str);
|
||||
yasm_xfree(str);
|
||||
|
||||
/* 32-bit (single precision) format */
|
||||
fprintf(f, "32-bit: %d: ", yasm_floatnum_get_sized(flt, out, 4));
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ HAMT *
|
|||
HAMT_new(/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message))
|
||||
{
|
||||
/*@out@*/ HAMT *hamt = xmalloc(sizeof(HAMT));
|
||||
/*@out@*/ HAMT *hamt = yasm_xmalloc(sizeof(HAMT));
|
||||
int i;
|
||||
|
||||
SLIST_INIT(&hamt->entries);
|
||||
hamt->root = xmalloc(32*sizeof(HAMTNode));
|
||||
hamt->root = yasm_xmalloc(32*sizeof(HAMTNode));
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
hamt->root[i].BitMapKey = 0;
|
||||
|
|
@ -115,7 +115,7 @@ HAMT_delete_trie(HAMTNode *node)
|
|||
|
||||
for (i=0; i<Size; i++)
|
||||
HAMT_delete_trie(&(GetSubTrie(node))[i]);
|
||||
xfree(GetSubTrie(node));
|
||||
yasm_xfree(GetSubTrie(node));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,15 +130,15 @@ HAMT_delete(HAMT *hamt, void (*deletefunc) (/*@only@*/ void *data))
|
|||
entry = SLIST_FIRST(&hamt->entries);
|
||||
SLIST_REMOVE_HEAD(&hamt->entries, next);
|
||||
deletefunc(entry->data);
|
||||
xfree(entry);
|
||||
yasm_xfree(entry);
|
||||
}
|
||||
|
||||
/* delete trie */
|
||||
for (i=0; i<32; i++)
|
||||
HAMT_delete_trie(&hamt->root[i]);
|
||||
|
||||
xfree(hamt->root);
|
||||
xfree(hamt);
|
||||
yasm_xfree(hamt->root);
|
||||
yasm_xfree(hamt);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -170,7 +170,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
|
||||
if (!node->BaseValue) {
|
||||
node->BitMapKey = key;
|
||||
entry = xmalloc(sizeof(HAMTEntry));
|
||||
entry = yasm_xmalloc(sizeof(HAMTEntry));
|
||||
entry->str = str;
|
||||
entry->data = data;
|
||||
SLIST_INSERT_HEAD(&hamt->entries, entry, next);
|
||||
|
|
@ -216,7 +216,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
/* Still equal, build one-node subtrie and continue
|
||||
* downward.
|
||||
*/
|
||||
newnodes = xmalloc(sizeof(HAMTNode));
|
||||
newnodes = yasm_xmalloc(sizeof(HAMTNode));
|
||||
newnodes[0] = *node; /* structure copy */
|
||||
node->BitMapKey = 1<<keypart;
|
||||
SetSubTrie(hamt, node, newnodes);
|
||||
|
|
@ -224,9 +224,9 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
level++;
|
||||
} else {
|
||||
/* partitioned: allocate two-node subtrie */
|
||||
newnodes = xmalloc(2*sizeof(HAMTNode));
|
||||
newnodes = yasm_xmalloc(2*sizeof(HAMTNode));
|
||||
|
||||
entry = xmalloc(sizeof(HAMTEntry));
|
||||
entry = yasm_xmalloc(sizeof(HAMTEntry));
|
||||
entry->str = str;
|
||||
entry->data = data;
|
||||
SLIST_INSERT_HEAD(&hamt->entries, entry, next);
|
||||
|
|
@ -270,7 +270,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
/* Count total number of bits in bitmap to determine new size */
|
||||
BitCount(Size, node->BitMapKey);
|
||||
Size &= 0x1F; /* Clamp to <32 */
|
||||
newnodes = xmalloc(Size*sizeof(HAMTNode));
|
||||
newnodes = yasm_xmalloc(Size*sizeof(HAMTNode));
|
||||
|
||||
/* Count bits below to find where to insert new node at */
|
||||
BitCount(Map, node->BitMapKey & ~((~0UL)<<keypart));
|
||||
|
|
@ -280,10 +280,10 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
memcpy(&newnodes[Map+1], &(GetSubTrie(node))[Map],
|
||||
(Size-Map-1)*sizeof(HAMTNode));
|
||||
/* Delete old subtrie */
|
||||
xfree(GetSubTrie(node));
|
||||
yasm_xfree(GetSubTrie(node));
|
||||
/* Set up new node */
|
||||
newnodes[Map].BitMapKey = key;
|
||||
entry = xmalloc(sizeof(HAMTEntry));
|
||||
entry = yasm_xmalloc(sizeof(HAMTEntry));
|
||||
entry->str = str;
|
||||
entry->data = data;
|
||||
SLIST_INSERT_HEAD(&hamt->entries, entry, next);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ yasm_intnum_cleanup(void)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_dec(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = 0; /* no reliable way to figure this out */
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ yasm_intnum_new_dec(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_bin(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = (unsigned char)strlen(str);
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ yasm_intnum_new_bin(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_oct(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = strlen(str)*3;
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ yasm_intnum_new_oct(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_hex(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = strlen(str)*4;
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ yasm_intnum_new_hex(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_charconst_nasm(const char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
size_t len = strlen(str);
|
||||
|
||||
if (len > 4)
|
||||
|
|
@ -195,7 +195,7 @@ yasm_intnum_new_charconst_nasm(const char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_uint(unsigned long i)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->val.ul = i;
|
||||
intn->type = INTNUM_UL;
|
||||
|
|
@ -214,7 +214,7 @@ yasm_intnum_new_int(long i)
|
|||
yasm_intnum *
|
||||
yasm_intnum_copy(const yasm_intnum *intn)
|
||||
{
|
||||
yasm_intnum *n = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *n = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
switch (intn->type) {
|
||||
case INTNUM_UL:
|
||||
|
|
@ -235,7 +235,7 @@ yasm_intnum_delete(yasm_intnum *intn)
|
|||
{
|
||||
if (intn->type == INTNUM_BV)
|
||||
BitVector_Destroy(intn->val.bv);
|
||||
xfree(intn);
|
||||
yasm_xfree(intn);
|
||||
}
|
||||
|
||||
/*@-nullderef -nullpass -branchstate@*/
|
||||
|
|
@ -561,7 +561,7 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, size_t size)
|
|||
if (len < (unsigned int)size)
|
||||
yasm_internal_error(N_("Invalid size specified (too large)"));
|
||||
memcpy(ptr, buf, size);
|
||||
xfree(buf);
|
||||
yasm_xfree(buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -644,7 +644,7 @@ yasm_intnum_print(FILE *f, const yasm_intnum *intn)
|
|||
case INTNUM_BV:
|
||||
s = BitVector_to_Hex(intn->val.bv);
|
||||
fprintf(f, "0x%s/%u", (char *)s, (unsigned int)intn->origsize);
|
||||
xfree(s);
|
||||
yasm_xfree(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ static line_index_assoc_data_raw_head *line_index_assoc_data_array;
|
|||
static void
|
||||
filename_delete_one(/*@only@*/ void *d)
|
||||
{
|
||||
xfree(d);
|
||||
yasm_xfree(d);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -95,8 +95,9 @@ yasm_std_linemgr_set(const char *filename, unsigned long line,
|
|||
/* Create a new mapping in the map */
|
||||
if (line_index_map->size >= line_index_map->allocated) {
|
||||
/* allocate another size bins when full for 2x space */
|
||||
line_index_map->vector = xrealloc(line_index_map->vector,
|
||||
2*line_index_map->allocated*sizeof(line_index_mapping));
|
||||
line_index_map->vector =
|
||||
yasm_xrealloc(line_index_map->vector, 2*line_index_map->allocated
|
||||
*sizeof(line_index_mapping));
|
||||
line_index_map->allocated *= 2;
|
||||
}
|
||||
mapping = &line_index_map->vector[line_index_map->size];
|
||||
|
|
@ -105,7 +106,7 @@ yasm_std_linemgr_set(const char *filename, unsigned long line,
|
|||
/* Fill it */
|
||||
|
||||
/* Copy the filename (via shared storage) */
|
||||
copy = xstrdup(filename);
|
||||
copy = yasm__xstrdup(filename);
|
||||
/*@-aliasunique@*/
|
||||
mapping->filename = HAMT_insert(filename_table, copy, copy, &replace,
|
||||
filename_delete_one);
|
||||
|
|
@ -126,15 +127,15 @@ yasm_std_linemgr_initialize(void)
|
|||
line_index = 1;
|
||||
|
||||
/* initialize mapping vector */
|
||||
line_index_map = xmalloc(sizeof(line_index_mapping_head));
|
||||
line_index_map->vector = xmalloc(8*sizeof(line_index_mapping));
|
||||
line_index_map = yasm_xmalloc(sizeof(line_index_mapping_head));
|
||||
line_index_map->vector = yasm_xmalloc(8*sizeof(line_index_mapping));
|
||||
line_index_map->size = 0;
|
||||
line_index_map->allocated = 8;
|
||||
|
||||
/* initialize associated data arrays */
|
||||
line_index_assoc_data_array =
|
||||
xmalloc(MAX_LINE_INDEX_ASSOC_DATA_ARRAY *
|
||||
sizeof(line_index_assoc_data_raw_head));
|
||||
yasm_xmalloc(MAX_LINE_INDEX_ASSOC_DATA_ARRAY *
|
||||
sizeof(line_index_assoc_data_raw_head));
|
||||
for (i=0; i<MAX_LINE_INDEX_ASSOC_DATA_ARRAY; i++) {
|
||||
line_index_assoc_data_array[i].vector = NULL;
|
||||
line_index_assoc_data_array[i].size = 0;
|
||||
|
|
@ -155,16 +156,16 @@ yasm_std_linemgr_cleanup(void)
|
|||
if (adrh->vector[j])
|
||||
adrh->delete_func(adrh->vector[j]);
|
||||
}
|
||||
xfree(adrh->vector);
|
||||
yasm_xfree(adrh->vector);
|
||||
}
|
||||
}
|
||||
xfree(line_index_assoc_data_array);
|
||||
yasm_xfree(line_index_assoc_data_array);
|
||||
line_index_assoc_data_array = NULL;
|
||||
}
|
||||
|
||||
if (line_index_map) {
|
||||
xfree(line_index_map->vector);
|
||||
xfree(line_index_map);
|
||||
yasm_xfree(line_index_map->vector);
|
||||
yasm_xfree(line_index_map);
|
||||
line_index_map = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +193,7 @@ yasm_std_linemgr_add_assoc_data(int type, /*@only@*/ void *data,
|
|||
int i;
|
||||
|
||||
adrh->size = 4;
|
||||
adrh->vector = xmalloc(adrh->size*sizeof(void *));
|
||||
adrh->vector = yasm_xmalloc(adrh->size*sizeof(void *));
|
||||
adrh->delete_func = delete_func;
|
||||
for (i=0; i<adrh->size; i++)
|
||||
adrh->vector[i] = NULL;
|
||||
|
|
@ -202,7 +203,8 @@ yasm_std_linemgr_add_assoc_data(int type, /*@only@*/ void *data,
|
|||
int i;
|
||||
|
||||
/* allocate another size bins when full for 2x space */
|
||||
adrh->vector = xrealloc(adrh->vector, 2*adrh->size*sizeof(void *));
|
||||
adrh->vector = yasm_xrealloc(adrh->vector,
|
||||
2*adrh->size*sizeof(void *));
|
||||
for(i=adrh->size; i<adrh->size*2; i++)
|
||||
adrh->vector[i] = NULL;
|
||||
adrh->size *= 2;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ yasm_sections_initialize(yasm_sectionhead *headp, yasm_objfmt *of)
|
|||
STAILQ_INIT(headp);
|
||||
|
||||
/* Add an initial "default" section */
|
||||
yasm_vp_new(vp, xstrdup(of->default_section_name), NULL);
|
||||
yasm_vp_new(vp, yasm__xstrdup(of->default_section_name), NULL);
|
||||
yasm_vps_initialize(&vps);
|
||||
yasm_vps_append(&vps, vp);
|
||||
s = of->sections_switch(headp, &vps, NULL, 0);
|
||||
|
|
@ -105,11 +105,11 @@ yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
|||
/* No: we have to allocate and create a new one. */
|
||||
|
||||
/* Okay, the name is valid; now allocate and initialize */
|
||||
s = xcalloc(1, sizeof(yasm_section));
|
||||
s = yasm_xcalloc(1, sizeof(yasm_section));
|
||||
STAILQ_INSERT_TAIL(headp, s, link);
|
||||
|
||||
s->type = SECTION_GENERAL;
|
||||
s->data.general.name = xstrdup(name);
|
||||
s->data.general.name = yasm__xstrdup(name);
|
||||
s->data.general.of = NULL;
|
||||
s->data.general.of_data = NULL;
|
||||
s->start = yasm_expr_new_ident(yasm_expr_int(yasm_intnum_new_uint(start)),
|
||||
|
|
@ -130,7 +130,7 @@ yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start)
|
|||
{
|
||||
yasm_section *s;
|
||||
|
||||
s = xcalloc(1, sizeof(yasm_section));
|
||||
s = yasm_xcalloc(1, sizeof(yasm_section));
|
||||
STAILQ_INSERT_TAIL(headp, s, link);
|
||||
|
||||
s->type = SECTION_ABSOLUTE;
|
||||
|
|
@ -290,7 +290,7 @@ yasm_section_delete(yasm_section *sect)
|
|||
return;
|
||||
|
||||
if (sect->type == SECTION_GENERAL) {
|
||||
xfree(sect->data.general.name);
|
||||
yasm_xfree(sect->data.general.name);
|
||||
if (sect->data.general.of_data && sect->data.general.of) {
|
||||
yasm_objfmt *of = sect->data.general.of;
|
||||
if (of->section_data_delete)
|
||||
|
|
@ -302,7 +302,7 @@ yasm_section_delete(yasm_section *sect)
|
|||
}
|
||||
yasm_expr_delete(sect->start);
|
||||
yasm_bcs_delete(§->bc);
|
||||
xfree(sect);
|
||||
yasm_xfree(sect);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void
|
|||
yasm_symrec_initialize(void)
|
||||
{
|
||||
sym_table = HAMT_new(yasm_internal_error_);
|
||||
non_table_syms = xmalloc(sizeof(nontablesymhead));
|
||||
non_table_syms = yasm_xmalloc(sizeof(nontablesymhead));
|
||||
SLIST_INIT(non_table_syms);
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ static void
|
|||
symrec_delete_one(/*@only@*/ void *d)
|
||||
{
|
||||
yasm_symrec *sym = d;
|
||||
xfree(sym->name);
|
||||
yasm_xfree(sym->name);
|
||||
if (sym->type == SYM_EQU)
|
||||
yasm_expr_delete(sym->value.expn);
|
||||
if (sym->of_data && sym->of) {
|
||||
|
|
@ -115,13 +115,13 @@ symrec_delete_one(/*@only@*/ void *d)
|
|||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific data"));
|
||||
}
|
||||
xfree(sym);
|
||||
yasm_xfree(sym);
|
||||
}
|
||||
|
||||
static /*@partial@*/ yasm_symrec *
|
||||
symrec_new_common(/*@keep@*/ char *name)
|
||||
{
|
||||
yasm_symrec *rec = xmalloc(sizeof(yasm_symrec));
|
||||
yasm_symrec *rec = yasm_xmalloc(sizeof(yasm_symrec));
|
||||
rec->name = name;
|
||||
rec->type = SYM_UNKNOWN;
|
||||
rec->line = 0;
|
||||
|
|
@ -146,7 +146,7 @@ symrec_get_or_new_in_table(/*@only@*/ char *name)
|
|||
static /*@partial@*/ /*@dependent@*/ yasm_symrec *
|
||||
symrec_get_or_new_not_in_table(/*@only@*/ char *name)
|
||||
{
|
||||
non_table_symrec *sym = xmalloc(sizeof(non_table_symrec));
|
||||
non_table_symrec *sym = yasm_xmalloc(sizeof(non_table_symrec));
|
||||
sym->rec = symrec_new_common(name);
|
||||
|
||||
sym->rec->status = SYM_NOTINTABLE;
|
||||
|
|
@ -161,7 +161,7 @@ symrec_get_or_new_not_in_table(/*@only@*/ char *name)
|
|||
static /*@partial@*/ /*@dependent@*/ yasm_symrec *
|
||||
symrec_get_or_new(const char *name, int in_table)
|
||||
{
|
||||
char *symname = xstrdup(name);
|
||||
char *symname = yasm__xstrdup(name);
|
||||
|
||||
if (in_table)
|
||||
return symrec_get_or_new_in_table(symname);
|
||||
|
|
@ -360,9 +360,9 @@ yasm_symrec_cleanup(void)
|
|||
non_table_symrec *sym = SLIST_FIRST(non_table_syms);
|
||||
SLIST_REMOVE_HEAD(non_table_syms, link);
|
||||
symrec_delete_one(sym->rec);
|
||||
xfree(sym);
|
||||
yasm_xfree(sym);
|
||||
}
|
||||
xfree(non_table_syms);
|
||||
yasm_xfree(non_table_syms);
|
||||
}
|
||||
|
||||
typedef struct symrec_print_data {
|
||||
|
|
|
|||
|
|
@ -126,21 +126,33 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* strdup() implementation with error checking (using xmalloc). */
|
||||
/*@only@*/ char *xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines in xmalloc.c. */
|
||||
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
|
||||
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
|
||||
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
|
||||
void *oldmem, size_t size) /*@modifies oldmem@*/;
|
||||
void xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p) /*@modifies p@*/;
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
# include <dmalloc.h>
|
||||
|
||||
#define yasm__xstrdup(str) xstrdup(str)
|
||||
#define yasm_xmalloc(size) xmalloc(size)
|
||||
#define yasm_xcalloc(count, size) xcalloc(count, size)
|
||||
#define yasm_xrealloc(ptr, size) xrealloc(ptr, size)
|
||||
#define yasm_xfree(ptr) xfree(ptr)
|
||||
|
||||
#else
|
||||
/* strdup() implementation with error checking (using xmalloc). */
|
||||
/*@only@*/ char *yasm__xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines. Default implementations in
|
||||
* xmalloc.c.
|
||||
*/
|
||||
extern /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size);
|
||||
extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize);
|
||||
extern /*@only@*/ void * (*yasm_xrealloc)
|
||||
(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size)
|
||||
/*@modifies oldmem@*/;
|
||||
extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
|
||||
/*@modifies p@*/;
|
||||
|
||||
#endif
|
||||
|
||||
/*@only@*/ char *xstrndup(const char *str, size_t len);
|
||||
/*@only@*/ char *yasm__xstrndup(const char *str, size_t len);
|
||||
|
||||
/* Bit-counting: used primarily by HAMT but also in a few other places. */
|
||||
#define SK5 0x55555555
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ yasm_vps_delete(yasm_valparamhead *headp)
|
|||
while (cur) {
|
||||
next = STAILQ_NEXT(cur, link);
|
||||
if (cur->val)
|
||||
xfree(cur->val);
|
||||
yasm_xfree(cur->val);
|
||||
if (cur->param)
|
||||
yasm_expr_delete(cur->param);
|
||||
xfree(cur);
|
||||
yasm_xfree(cur);
|
||||
cur = next;
|
||||
}
|
||||
STAILQ_INIT(headp);
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ typedef /*@reldef@*/ STAILQ_HEAD(yasm_valparamhead, yasm_valparam)
|
|||
|
||||
void yasm_vp_new(/*@out@*/ yasm_valparam *r, /*@keep@*/ const char *v,
|
||||
/*@keep@*/ yasm_expr *p);
|
||||
#define yasm_vp_new(r, v, p) do { \
|
||||
r = xmalloc(sizeof(yasm_valparam)); \
|
||||
r->val = v; \
|
||||
r->param = p; \
|
||||
#define yasm_vp_new(r, v, p) do { \
|
||||
r = yasm_xmalloc(sizeof(yasm_valparam)); \
|
||||
r->val = v; \
|
||||
r->param = p; \
|
||||
} while(0)
|
||||
|
||||
/* void yasm_vps_initialize(//@out@// yasm_valparamhead *headp); */
|
||||
|
|
|
|||
|
|
@ -32,8 +32,26 @@ RCSID("$IdPath$");
|
|||
|
||||
#ifndef WITH_DMALLOC
|
||||
|
||||
void *
|
||||
xmalloc(size_t size)
|
||||
static /*@only@*/ /*@out@*/ void *def_xmalloc(size_t size);
|
||||
static /*@only@*/ void *def_xcalloc(size_t nelem, size_t elsize);
|
||||
static /*@only@*/ void *def_xrealloc
|
||||
(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size)
|
||||
/*@modifies oldmem@*/;
|
||||
static void def_xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p)
|
||||
/*@modifies p@*/;
|
||||
|
||||
/* storage for global function pointers */
|
||||
/*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size) = def_xmalloc;
|
||||
/*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize) = def_xcalloc;
|
||||
/*@only@*/ void * (*yasm_xrealloc)
|
||||
(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size)
|
||||
/*@modifies oldmem@*/ = def_xrealloc;
|
||||
void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
|
||||
/*@modifies p@*/ = def_xfree;
|
||||
|
||||
|
||||
static void *
|
||||
def_xmalloc(size_t size)
|
||||
{
|
||||
void *newmem;
|
||||
|
||||
|
|
@ -46,8 +64,8 @@ xmalloc(size_t size)
|
|||
return newmem;
|
||||
}
|
||||
|
||||
void *
|
||||
xcalloc(size_t nelem, size_t elsize)
|
||||
static void *
|
||||
def_xcalloc(size_t nelem, size_t elsize)
|
||||
{
|
||||
void *newmem;
|
||||
|
||||
|
|
@ -61,8 +79,8 @@ xcalloc(size_t nelem, size_t elsize)
|
|||
return newmem;
|
||||
}
|
||||
|
||||
void *
|
||||
xrealloc(void *oldmem, size_t size)
|
||||
static void *
|
||||
def_xrealloc(void *oldmem, size_t size)
|
||||
{
|
||||
void *newmem;
|
||||
|
||||
|
|
@ -78,8 +96,8 @@ xrealloc(void *oldmem, size_t size)
|
|||
return newmem;
|
||||
}
|
||||
|
||||
void
|
||||
xfree(void *p)
|
||||
static void
|
||||
def_xfree(void *p)
|
||||
{
|
||||
if (!p)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -50,24 +50,24 @@ void memcpy(void *, const void *, size_t);
|
|||
#ifndef WITH_DMALLOC
|
||||
|
||||
char *
|
||||
xstrdup(const char *str)
|
||||
yasm__xstrdup(const char *str)
|
||||
{
|
||||
size_t len;
|
||||
char *copy;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
copy = xmalloc(len);
|
||||
copy = yasm_xmalloc(len);
|
||||
memcpy(copy, str, len);
|
||||
return (copy);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
xstrndup(const char *str, size_t len)
|
||||
yasm__xstrndup(const char *str, size_t len)
|
||||
{
|
||||
char *copy;
|
||||
|
||||
copy = xmalloc(len+1);
|
||||
copy = yasm_xmalloc(len+1);
|
||||
memcpy(copy, str, len);
|
||||
copy[len] = '\0';
|
||||
return (copy);
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex, unsigned char bits)
|
|||
if (yasm_x86__set_rex_from_reg(rex, &rm, reg, bits, X86_REX_B))
|
||||
return NULL;
|
||||
|
||||
x86_ea = xmalloc(sizeof(x86_effaddr));
|
||||
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
|
||||
|
||||
x86_ea->ea.disp = (yasm_expr *)NULL;
|
||||
x86_ea->ea.len = 0;
|
||||
|
|
@ -285,7 +285,7 @@ yasm_x86__ea_new_expr(yasm_expr *e)
|
|||
{
|
||||
x86_effaddr *x86_ea;
|
||||
|
||||
x86_ea = xmalloc(sizeof(x86_effaddr));
|
||||
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
|
||||
|
||||
x86_ea->ea.disp = e;
|
||||
x86_ea->ea.len = 0;
|
||||
|
|
@ -310,7 +310,7 @@ yasm_x86__ea_new_imm(yasm_expr *imm, unsigned char im_len)
|
|||
{
|
||||
x86_effaddr *x86_ea;
|
||||
|
||||
x86_ea = xmalloc(sizeof(x86_effaddr));
|
||||
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
|
||||
|
||||
x86_ea->ea.disp = imm;
|
||||
x86_ea->ea.len = im_len;
|
||||
|
|
@ -432,7 +432,7 @@ yasm_x86__bc_delete(yasm_bytecode *bc)
|
|||
yasm_ea_delete((yasm_effaddr *)insn->ea);
|
||||
if (insn->imm) {
|
||||
yasm_expr_delete(insn->imm->val);
|
||||
xfree(insn->imm);
|
||||
yasm_xfree(insn->imm);
|
||||
}
|
||||
break;
|
||||
case X86_BC_JMPREL:
|
||||
|
|
@ -645,7 +645,7 @@ x86_bc_resolve_insn(x86_insn *insn, unsigned long *len, int save,
|
|||
insn->opcode[0] = insn->opcode[1];
|
||||
/* Delete imm, as it's not needed. */
|
||||
yasm_expr_delete(imm->val);
|
||||
xfree(imm);
|
||||
yasm_xfree(imm);
|
||||
insn->imm = (yasm_immval *)NULL;
|
||||
}
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -2071,7 +2071,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
if (d.ea)
|
||||
xfree(d.ea);
|
||||
yasm_xfree(d.ea);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Don't bother doing anything else if size ended up being 0. */
|
||||
if (size == 0) {
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
|
||||
/* If bigbuf was allocated, free it */
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
bin_objfmt_output_info info;
|
||||
|
||||
info.f = f;
|
||||
info.buf = xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
|
||||
text = yasm_sections_find_general(sections, ".text");
|
||||
data = yasm_sections_find_general(sections, ".data");
|
||||
|
|
@ -311,7 +311,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
/* If .bss is present, check it for non-reserve bytecodes */
|
||||
|
||||
|
||||
xfree(info.buf);
|
||||
yasm_xfree(info.buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -396,7 +396,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
if (isnew) {
|
||||
if (have_alignval) {
|
||||
unsigned long *data = xmalloc(sizeof(unsigned long));
|
||||
unsigned long *data = yasm_xmalloc(sizeof(unsigned long));
|
||||
*data = alignval;
|
||||
yasm_section_set_of_data(retval, &yasm_bin_LTX_objfmt, data);
|
||||
}
|
||||
|
|
@ -415,7 +415,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
static void
|
||||
bin_objfmt_section_data_delete(/*@only@*/ void *d)
|
||||
{
|
||||
xfree(d);
|
||||
yasm_xfree(d);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -180,14 +180,14 @@ coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass,
|
|||
sym_data_prev = yasm_symrec_get_of_data(entry->sym);
|
||||
assert(sym_data_prev != NULL);
|
||||
|
||||
sym_data = xmalloc(sizeof(coff_symrec_data));
|
||||
sym_data = yasm_xmalloc(sizeof(coff_symrec_data));
|
||||
sym_data->index = sym_data_prev->index + entry->numaux + 1;
|
||||
sym_data->sclass = sclass;
|
||||
sym_data->size = size;
|
||||
yasm_symrec_set_of_data(sym, &yasm_coff_LTX_objfmt, sym_data);
|
||||
|
||||
entry = xmalloc(sizeof(coff_symtab_entry) +
|
||||
(numaux-1)*sizeof(coff_symtab_auxent));
|
||||
entry = yasm_xmalloc(sizeof(coff_symtab_entry) +
|
||||
(numaux-1)*sizeof(coff_symtab_auxent));
|
||||
entry->sym = sym;
|
||||
entry->numaux = numaux;
|
||||
entry->auxtype = auxtype;
|
||||
|
|
@ -210,18 +210,18 @@ coff_objfmt_initialize(const char *in_filename,
|
|||
coff_objfmt_parse_scnum = 1; /* section numbering starts at 1 */
|
||||
STAILQ_INIT(&coff_symtab);
|
||||
|
||||
data = xmalloc(sizeof(coff_symrec_data));
|
||||
data = yasm_xmalloc(sizeof(coff_symrec_data));
|
||||
data->index = 0;
|
||||
data->sclass = COFF_SCL_FILE;
|
||||
data->size = NULL;
|
||||
filesym = yasm_symrec_define_label(".file", NULL, NULL, 0, 0);
|
||||
yasm_symrec_set_of_data(filesym, &yasm_coff_LTX_objfmt, data);
|
||||
|
||||
entry = xmalloc(sizeof(coff_symtab_entry));
|
||||
entry = yasm_xmalloc(sizeof(coff_symtab_entry));
|
||||
entry->sym = filesym;
|
||||
entry->numaux = 1;
|
||||
entry->auxtype = COFF_SYMTAB_AUX_FILE;
|
||||
entry->aux[0].fname = xstrdup(in_filename);
|
||||
entry->aux[0].fname = yasm__xstrdup(in_filename);
|
||||
STAILQ_INSERT_TAIL(&coff_symtab, entry, link);
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
return 1;
|
||||
}
|
||||
|
||||
reloc = xmalloc(sizeof(coff_reloc));
|
||||
reloc = yasm_xmalloc(sizeof(coff_reloc));
|
||||
reloc->addr = bc->offset + offset;
|
||||
if (COFF_SET_VMA)
|
||||
reloc->addr += info->addr;
|
||||
|
|
@ -357,7 +357,7 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Don't bother doing anything else if size ended up being 0. */
|
||||
if (size == 0) {
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -384,7 +384,7 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
|
||||
/* If bigbuf was allocated, free it */
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -519,7 +519,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
coff_symtab_entry *entry;
|
||||
|
||||
info.f = f;
|
||||
info.buf = xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
|
||||
/* Allocate space for headers by seeking forward */
|
||||
if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
|
||||
|
|
@ -686,7 +686,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
|
||||
yasm_sections_traverse(sections, &info, coff_objfmt_output_secthead);
|
||||
|
||||
xfree(info.buf);
|
||||
yasm_xfree(info.buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -699,8 +699,8 @@ coff_objfmt_cleanup(void)
|
|||
while (entry1 != NULL) {
|
||||
entry2 = STAILQ_NEXT(entry1, link);
|
||||
if (entry1->numaux == 1 && entry1->auxtype == COFF_SYMTAB_AUX_FILE)
|
||||
xfree(entry1->aux[0].fname);
|
||||
xfree(entry1);
|
||||
yasm_xfree(entry1->aux[0].fname);
|
||||
yasm_xfree(entry1);
|
||||
entry1 = entry2;
|
||||
}
|
||||
}
|
||||
|
|
@ -760,7 +760,7 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
coff_section_data *data;
|
||||
yasm_symrec *sym;
|
||||
|
||||
data = xmalloc(sizeof(coff_section_data));
|
||||
data = yasm_xmalloc(sizeof(coff_section_data));
|
||||
data->scnum = coff_objfmt_parse_scnum++;
|
||||
data->flags = flags;
|
||||
data->addr = 0;
|
||||
|
|
@ -790,10 +790,10 @@ coff_objfmt_section_data_delete(/*@only@*/ void *data)
|
|||
r1 = STAILQ_FIRST(&csd->relocs);
|
||||
while (r1 != NULL) {
|
||||
r2 = STAILQ_NEXT(r1, link);
|
||||
xfree(r1);
|
||||
yasm_xfree(r1);
|
||||
r1 = r2;
|
||||
}
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -868,7 +868,7 @@ coff_objfmt_symrec_data_delete(/*@only@*/ void *data)
|
|||
coff_symrec_data *csymd = (coff_symrec_data *)data;
|
||||
if (csymd->size)
|
||||
yasm_expr_delete(csymd->size);
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static void
|
|||
dbg_objfmt_section_data_delete(/*@only@*/ void *data)
|
||||
{
|
||||
fprintf(dbg_objfmt_file, "section_data_delete(%p)\n", data);
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -214,7 +214,7 @@ static void
|
|||
dbg_objfmt_bc_objfmt_data_delete(unsigned int type, /*@only@*/ void *data)
|
||||
{
|
||||
fprintf(dbg_objfmt_file, "symrec_data_delete(%u, %p)\n", type, data);
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ line: '\n' { $$ = (yasm_bytecode *)NULL; }
|
|||
yasm_intnum_get_uint($4));
|
||||
yasm_intnum_delete($2);
|
||||
yasm_intnum_delete($4);
|
||||
xfree($5);
|
||||
yasm_xfree($5);
|
||||
$$ = (yasm_bytecode *)NULL;
|
||||
}
|
||||
| '[' { nasm_parser_set_directive_state(); } directive ']' '\n' {
|
||||
|
|
@ -169,7 +169,7 @@ lineexp: exp
|
|||
| label TIMES expr exp { $$ = $4; yasm_bc_set_multiple($$, $3); }
|
||||
| label_id_equ EQU expr {
|
||||
yasm_symrec_define_equ($1, $3, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
$$ = (yasm_bytecode *)NULL;
|
||||
}
|
||||
;
|
||||
|
|
@ -236,22 +236,22 @@ dataval: dvexpr { $$ = yasm_dv_new_expr($1); }
|
|||
label: label_id {
|
||||
yasm_symrec_define_label($1, nasm_parser_cur_section,
|
||||
nasm_parser_prev_bc, 1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| label_id ':' {
|
||||
yasm_symrec_define_label($1, nasm_parser_cur_section,
|
||||
nasm_parser_prev_bc, 1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
;
|
||||
|
||||
label_id: ID {
|
||||
$$ = $1;
|
||||
if (nasm_parser_locallabel_base)
|
||||
xfree(nasm_parser_locallabel_base);
|
||||
yasm_xfree(nasm_parser_locallabel_base);
|
||||
nasm_parser_locallabel_base_len = strlen($1);
|
||||
nasm_parser_locallabel_base =
|
||||
xmalloc(nasm_parser_locallabel_base_len+1);
|
||||
yasm_xmalloc(nasm_parser_locallabel_base_len+1);
|
||||
strcpy(nasm_parser_locallabel_base, $1);
|
||||
}
|
||||
| SPECIAL_ID
|
||||
|
|
@ -265,11 +265,11 @@ label_id_equ: ID
|
|||
|
||||
/* directives */
|
||||
directive: DIRECTIVE_NAME directive_val {
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| DIRECTIVE_NAME error {
|
||||
yasm__error(cur_lindex, N_("invalid arguments to [%s]"), $1);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -304,7 +304,8 @@ directive_valparam: direxpr {
|
|||
*/
|
||||
const /*@null@*/ yasm_symrec *vp_symrec;
|
||||
if ((vp_symrec = yasm_expr_get_symrec(&$1, 0))) {
|
||||
yasm_vp_new($$, xstrdup(yasm_symrec_get_name(vp_symrec)), NULL);
|
||||
yasm_vp_new($$, yasm__xstrdup(yasm_symrec_get_name(vp_symrec)),
|
||||
NULL);
|
||||
yasm_expr_delete($1);
|
||||
} else {
|
||||
yasm_expr__traverse_leaves_in($1, NULL, fix_directive_symrec);
|
||||
|
|
@ -407,7 +408,7 @@ direxpr: INTNUM { $$ = p_expr_new_ident(yasm_expr_int($1)); }
|
|||
| ID {
|
||||
$$ = p_expr_new_ident(yasm_expr_sym(
|
||||
yasm_symrec_define_label($1, NULL, NULL, 0, cur_lindex)));
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| direxpr '|' direxpr { $$ = p_expr_new_tree($1, YASM_EXPR_OR, $3); }
|
||||
| direxpr '^' direxpr { $$ = p_expr_new_tree($1, YASM_EXPR_XOR, $3); }
|
||||
|
|
@ -468,7 +469,7 @@ expr: INTNUM { $$ = p_expr_new_ident(yasm_expr_int($1)); }
|
|||
| STRING {
|
||||
$$ = p_expr_new_ident(yasm_expr_int(
|
||||
yasm_intnum_new_charconst_nasm($1, cur_lindex)));
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| explabel { $$ = p_expr_new_ident(yasm_expr_sym($1)); }
|
||||
/*| expr '||' expr { $$ = p_expr_new_tree($1, YASM_EXPR_LOR, $3); }*/
|
||||
|
|
@ -503,15 +504,15 @@ expr: INTNUM { $$ = p_expr_new_ident(yasm_expr_int($1)); }
|
|||
|
||||
explabel: ID {
|
||||
$$ = yasm_symrec_use($1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| SPECIAL_ID {
|
||||
$$ = yasm_symrec_use($1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| LOCAL_ID {
|
||||
$$ = yasm_symrec_use($1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| '$' {
|
||||
/* "$" references the current assembly position */
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ nasm_parser_do_parse(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of,
|
|||
|
||||
/* Free locallabel base if necessary */
|
||||
if (nasm_parser_locallabel_base)
|
||||
xfree(nasm_parser_locallabel_base);
|
||||
yasm_xfree(nasm_parser_locallabel_base);
|
||||
|
||||
return &nasm_parser_sections;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ fill(YYCTYPE *cursor)
|
|||
if (!s.bot)
|
||||
first = 1;
|
||||
if((s.top - s.lim) < BSIZE){
|
||||
char *buf = xmalloc((s.lim - s.bot) + BSIZE);
|
||||
char *buf = yasm_xmalloc((s.lim - s.bot) + BSIZE);
|
||||
memcpy(buf, s.tok, s.lim - s.tok);
|
||||
s.tok = buf;
|
||||
s.ptr = &buf[s.ptr - s.bot];
|
||||
|
|
@ -101,7 +101,7 @@ fill(YYCTYPE *cursor)
|
|||
s.lim = &buf[s.lim - s.bot];
|
||||
s.top = &s.lim[BSIZE];
|
||||
if (s.bot)
|
||||
xfree(s.bot);
|
||||
yasm_xfree(s.bot);
|
||||
s.bot = buf;
|
||||
}
|
||||
if((cnt = nasm_parser_input(s.lim, BSIZE)) == 0){
|
||||
|
|
@ -122,7 +122,7 @@ fill(YYCTYPE *cursor)
|
|||
static void
|
||||
delete_line(/*@only@*/ void *data)
|
||||
{
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static YYCTYPE *
|
||||
|
|
@ -132,7 +132,7 @@ save_line(YYCTYPE *cursor)
|
|||
|
||||
/* save previous line using assoc_data */
|
||||
nasm_parser_linemgr->add_assoc_data(YASM_LINEMGR_STD_TYPE_SOURCE,
|
||||
xstrdup(cur_line), delete_line);
|
||||
yasm__xstrdup(cur_line), delete_line);
|
||||
/* save next line into cur_line */
|
||||
if ((YYLIMIT - YYCURSOR) < 80)
|
||||
YYFILL(80);
|
||||
|
|
@ -146,7 +146,7 @@ void
|
|||
nasm_parser_cleanup(void)
|
||||
{
|
||||
if (s.bot)
|
||||
xfree(s.bot);
|
||||
yasm_xfree(s.bot);
|
||||
}
|
||||
|
||||
/* starting size of string buffer */
|
||||
|
|
@ -355,7 +355,7 @@ scan:
|
|||
|
||||
/* special non-local ..@label and labels like ..start */
|
||||
".." [a-zA-Z0-9_$#@~.?]+ {
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(SPECIAL_ID);
|
||||
}
|
||||
|
||||
|
|
@ -363,15 +363,15 @@ scan:
|
|||
"." [a-zA-Z0-9_$#@~?][a-zA-Z0-9_$#@~.?]* {
|
||||
/* override local labels in directive state */
|
||||
if (state == DIRECTIVE2) {
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
} else if (!nasm_parser_locallabel_base) {
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("no non-local label before `%s'"), s.tok[0]);
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
} else {
|
||||
len = TOKLEN + nasm_parser_locallabel_base_len;
|
||||
yylval.str_val = xmalloc(len + 1);
|
||||
yylval.str_val = yasm_xmalloc(len + 1);
|
||||
strcpy(yylval.str_val, nasm_parser_locallabel_base);
|
||||
strncat(yylval.str_val, s.tok, TOKLEN);
|
||||
yylval.str_val[len] = '\0';
|
||||
|
|
@ -382,7 +382,7 @@ scan:
|
|||
|
||||
/* forced identifier */
|
||||
"$" [a-zA-Z_?][a-zA-Z0-9_$#@~.?]* {
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ scan:
|
|||
switch (check_id_ret) {
|
||||
case YASM_ARCH_CHECK_ID_NONE:
|
||||
/* Just an identifier, return as such. */
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
case YASM_ARCH_CHECK_ID_INSN:
|
||||
RETURN(INSN);
|
||||
|
|
@ -411,7 +411,7 @@ scan:
|
|||
default:
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("Arch feature not supported, treating as identifier"));
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
}
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ linechg2:
|
|||
|
||||
(any \ [\r\n])+ {
|
||||
state = LINECHG;
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(FILENAME);
|
||||
}
|
||||
*/
|
||||
|
|
@ -510,7 +510,7 @@ directive:
|
|||
|
||||
iletter+ {
|
||||
state = DIRECTIVE2;
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(DIRECTIVE_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ directive:
|
|||
|
||||
/* string/character constant values */
|
||||
stringconst:
|
||||
strbuf = xmalloc(STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);
|
||||
strbuf_size = STRBUF_ALLOC_SIZE;
|
||||
count = 0;
|
||||
|
||||
|
|
@ -554,7 +554,7 @@ stringconst_scan:
|
|||
|
||||
strbuf[count++] = s.tok[0];
|
||||
if (count >= strbuf_size) {
|
||||
strbuf = xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf_size += STRBUF_ALLOC_SIZE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ nasm_preproc_input(char *buf, size_t max_size)
|
|||
tot += n;
|
||||
|
||||
if (n == lineleft) {
|
||||
xfree(line);
|
||||
yasm_xfree(line);
|
||||
line = NULL;
|
||||
} else {
|
||||
lineleft -= n;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
* passed a NULL pointer; nasm_free will do nothing if it is passed
|
||||
* a NULL pointer.
|
||||
*/
|
||||
#define nasm_malloc xmalloc
|
||||
#define nasm_realloc xrealloc
|
||||
#define nasm_free(p) if (p) xfree(p)
|
||||
#define nasm_strdup xstrdup
|
||||
#define nasm_strndup xstrndup
|
||||
#define nasm_malloc yasm_xmalloc
|
||||
#define nasm_realloc yasm_xrealloc
|
||||
#define nasm_free(p) yasm_xfree(p)
|
||||
#define nasm_strdup yasm__xstrdup
|
||||
#define nasm_strndup yasm__xstrndup
|
||||
#define nasm_stricmp yasm__strcasecmp
|
||||
#define nasm_strnicmp yasm__strncasecmp
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ replay_saved_tokens(char *ident,
|
|||
YAPP_Macro *
|
||||
yapp_macro_insert (char *name, int argc, int fillargs)
|
||||
{
|
||||
YAPP_Macro *ym = xmalloc(sizeof(YAPP_Macro));
|
||||
YAPP_Macro *ym = yasm_xmalloc(sizeof(YAPP_Macro));
|
||||
ym->type = YAPP_MACRO;
|
||||
ym->args = argc;
|
||||
ym->fillargs = fillargs;
|
||||
|
|
@ -147,7 +147,7 @@ yapp_define_insert (char *name, int argc, int fillargs)
|
|||
else if (argc >= 0)
|
||||
{
|
||||
/* insert placeholder for paramlisted defines */
|
||||
ym = xmalloc(sizeof(YAPP_Macro));
|
||||
ym = yasm_xmalloc(sizeof(YAPP_Macro));
|
||||
ym->type = YAPP_DEFINE;
|
||||
ym->args = argc;
|
||||
ym->fillargs = fillargs;
|
||||
|
|
@ -156,14 +156,14 @@ yapp_define_insert (char *name, int argc, int fillargs)
|
|||
}
|
||||
|
||||
/* now for the real one */
|
||||
ym = xmalloc(sizeof(YAPP_Macro));
|
||||
ym = yasm_xmalloc(sizeof(YAPP_Macro));
|
||||
ym->type = YAPP_DEFINE;
|
||||
ym->args = argc;
|
||||
ym->fillargs = fillargs;
|
||||
ym->expanding = 0;
|
||||
|
||||
if (argc>=0) {
|
||||
mungename = xmalloc(strlen(name)+8);
|
||||
mungename = yasm_xmalloc(strlen(name)+8);
|
||||
sprintf(mungename, "%s(%d)", name, argc);
|
||||
}
|
||||
|
||||
|
|
@ -188,10 +188,10 @@ yapp_macro_delete (YAPP_Macro *ym)
|
|||
{
|
||||
while (!SLIST_EMPTY(&ym->macro_head)) {
|
||||
source *s = SLIST_FIRST(&ym->macro_head);
|
||||
xfree(s);
|
||||
yasm_xfree(s);
|
||||
SLIST_REMOVE_HEAD(&ym->macro_head, next);
|
||||
}
|
||||
xfree(ym);
|
||||
yasm_xfree(ym);
|
||||
}
|
||||
|
||||
static YAPP_Macro *
|
||||
|
|
@ -240,14 +240,14 @@ yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
|||
{
|
||||
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
|
||||
yapp_preproc_linemgr = lm;
|
||||
yapp_preproc_current_file = xstrdup(in_filename);
|
||||
yapp_preproc_current_file = yasm__xstrdup(in_filename);
|
||||
yapp_preproc_line_number = 1;
|
||||
yapp_lex_initialize(f);
|
||||
SLIST_INIT(&output_head);
|
||||
SLIST_INIT(&source_head);
|
||||
SLIST_INIT(¯o_head);
|
||||
SLIST_INIT(¶m_head);
|
||||
out = xmalloc(sizeof(output));
|
||||
out = yasm_xmalloc(sizeof(output));
|
||||
out->out = current_output = YAPP_OUTPUT;
|
||||
SLIST_INSERT_HEAD(&output_head, out, next);
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ yapp_preproc_cleanup(void)
|
|||
static void
|
||||
push_if(int val)
|
||||
{
|
||||
out = xmalloc(sizeof(output));
|
||||
out = yasm_xmalloc(sizeof(output));
|
||||
out->out = current_output;
|
||||
SLIST_INSERT_HEAD(&output_head, out, next);
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ pop_if(void)
|
|||
out = SLIST_FIRST(&output_head);
|
||||
current_output = out->out;
|
||||
SLIST_REMOVE_HEAD(&output_head, next);
|
||||
xfree(out);
|
||||
yasm_xfree(out);
|
||||
if (current_output != YAPP_OUTPUT) set_inhibit();
|
||||
}
|
||||
|
||||
|
|
@ -373,49 +373,49 @@ append_token(int token, struct source_head *to_head, source **to_tail)
|
|||
if ((*to_tail) && (*to_tail)->token.type == LINE
|
||||
&& (token == '\n' || token == LINE))
|
||||
{
|
||||
xfree ((*to_tail)->token.str);
|
||||
(*to_tail)->token.str = xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
yasm_xfree ((*to_tail)->token.str);
|
||||
(*to_tail)->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
sprintf((*to_tail)->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file);
|
||||
}
|
||||
else {
|
||||
src = xmalloc(sizeof(source));
|
||||
src = yasm_xmalloc(sizeof(source));
|
||||
src->token.type = token;
|
||||
switch (token)
|
||||
{
|
||||
case INTNUM:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.int_str_val.str);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.int_str_val.str);
|
||||
src->token.val.int_val = yapp_preproc_lval.int_str_val.val;
|
||||
break;
|
||||
|
||||
case FLTNUM:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.double_str_val.str);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.double_str_val.str);
|
||||
src->token.val.double_val = yapp_preproc_lval.double_str_val.val;
|
||||
break;
|
||||
|
||||
case STRING:
|
||||
case WHITESPACE:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.str_val);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val);
|
||||
break;
|
||||
|
||||
case IDENT:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.str_val);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val);
|
||||
break;
|
||||
|
||||
case '+': case '-': case '*': case '/': case '%': case ',': case '\n':
|
||||
case '[': case ']': case '(': case ')':
|
||||
src->token.str = xmalloc(2);
|
||||
src->token.str = yasm_xmalloc(2);
|
||||
src->token.str[0] = (char)token;
|
||||
src->token.str[1] = '\0';
|
||||
break;
|
||||
|
||||
case LINE:
|
||||
/* TODO: consider removing any trailing newline or LINE tokens */
|
||||
src->token.str = xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
src->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
sprintf(src->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file);
|
||||
break;
|
||||
|
||||
default:
|
||||
xfree(src);
|
||||
yasm_xfree(src);
|
||||
return;
|
||||
}
|
||||
append_processed_token(src, to_head, to_tail);
|
||||
|
|
@ -488,9 +488,9 @@ yapp_get_ident(const char *synlvl)
|
|||
void
|
||||
copy_token(YAPP_Token *tok, struct source_head *to_head, source **to_tail)
|
||||
{
|
||||
src = xmalloc(sizeof(source));
|
||||
src = yasm_xmalloc(sizeof(source));
|
||||
src->token.type = tok->type;
|
||||
src->token.str = xstrdup(tok->str);
|
||||
src->token.str = yasm__xstrdup(tok->str);
|
||||
|
||||
append_processed_token(src, to_head, to_tail);
|
||||
}
|
||||
|
|
@ -594,14 +594,14 @@ expand_macro(char *name,
|
|||
}
|
||||
|
||||
/* Now we have the argument count; let's see if it exists */
|
||||
mungename = xmalloc(strlen(name)+8);
|
||||
mungename = yasm_xmalloc(strlen(name)+8);
|
||||
sprintf(mungename, "%s(%d)", name, argc);
|
||||
ym = yapp_macro_get(mungename);
|
||||
if (!ym)
|
||||
{
|
||||
ydebug(("YAPP: -Didn't find macro %s\n", mungename));
|
||||
replay_saved_tokens(name, &replay_head, to_head, to_tail);
|
||||
xfree(mungename);
|
||||
yasm_xfree(mungename);
|
||||
return;
|
||||
}
|
||||
ydebug(("YAPP: +Found macro %s\n", mungename));
|
||||
|
|
@ -618,16 +618,16 @@ expand_macro(char *name,
|
|||
while (replay->token.type != '(') {
|
||||
ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str));
|
||||
SLIST_REMOVE_HEAD(&replay_head, next);
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
replay = SLIST_FIRST(&replay_head);
|
||||
}
|
||||
ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str));
|
||||
|
||||
/* free the open paren */
|
||||
SLIST_REMOVE_HEAD(&replay_head, next);
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
|
||||
param = SLIST_FIRST(&ym->param_head);
|
||||
|
||||
|
|
@ -651,14 +651,14 @@ expand_macro(char *name,
|
|||
|| replay->token.type == ')'))
|
||||
{
|
||||
int zero=0;
|
||||
struct source_head *argmacro = xmalloc(sizeof(struct source_head));
|
||||
struct source_head *argmacro = yasm_xmalloc(sizeof(struct source_head));
|
||||
memcpy(argmacro, &arg_head, sizeof(struct source_head));
|
||||
SLIST_INIT(&arg_head);
|
||||
arg_tail = SLIST_FIRST(&arg_head);
|
||||
|
||||
/* don't save the comma */
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
|
||||
HAMT_insert(param_table,
|
||||
param->token.str,
|
||||
|
|
@ -681,8 +681,8 @@ expand_macro(char *name,
|
|||
if (replay) SLIST_REMOVE_HEAD(&replay_head, next);
|
||||
}
|
||||
if (replay) {
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
}
|
||||
else if (param) {
|
||||
yasm_internal_error(N_("Got to end of arglist before end of replay!"));
|
||||
|
|
@ -799,7 +799,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
ydebug(("YAPP: define: "));
|
||||
token = yapp_get_ident("define");
|
||||
ydebug((" \"%s\"\n", yapp_preproc_lval.str_val));
|
||||
s = xstrdup(yapp_preproc_lval.str_val);
|
||||
s = yasm__xstrdup(yapp_preproc_lval.str_val);
|
||||
|
||||
/* three cases: newline or stuff or left paren */
|
||||
token = yapp_preproc_lex();
|
||||
|
|
@ -936,8 +936,8 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
|
||||
saved_length -= strlen(src->token.str);
|
||||
SLIST_REMOVE_HEAD(&source_head, next);
|
||||
xfree(src->token.str);
|
||||
xfree(src);
|
||||
yasm_xfree(src->token.str);
|
||||
yasm_xfree(src);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@
|
|||
|
||||
#define yylval yapp_preproc_lval
|
||||
|
||||
#define malloc yasm_xmalloc
|
||||
#define realloc yasm_xrealloc
|
||||
|
||||
/* starting size of string buffer */
|
||||
#define STRBUF_ALLOC_SIZE 128
|
||||
|
||||
|
|
@ -124,7 +127,7 @@ DIR %[ \t]*
|
|||
int inch, count;
|
||||
char endch = yytext[0];
|
||||
|
||||
strbuf = xmalloc(STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);
|
||||
|
||||
strbuf_size = STRBUF_ALLOC_SIZE;
|
||||
inch = input();
|
||||
|
|
@ -132,7 +135,7 @@ DIR %[ \t]*
|
|||
while(inch != EOF && inch != endch && inch != '\n') {
|
||||
strbuf[count++] = inch;
|
||||
if(count >= strbuf_size) {
|
||||
strbuf = xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf_size += STRBUF_ALLOC_SIZE;
|
||||
}
|
||||
inch = input();
|
||||
|
|
@ -153,7 +156,7 @@ DIR %[ \t]*
|
|||
\.\.[a-z0-9_$#@~.?]+ |
|
||||
\.[a-z0-9_$#@~?][a-z0-9_$#@~.?]* |
|
||||
[a-z_?][a-z0-9_$#@~.?]* {
|
||||
yylval.str_val = xstrdup(yytext);
|
||||
yylval.str_val = yasm__xstrdup(yytext);
|
||||
return IDENT;
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +169,7 @@ DIR %[ \t]*
|
|||
<incl>[^ \t\n"]* { /* have the filename */
|
||||
include *inc;
|
||||
FILE *incfile;
|
||||
inc = xmalloc(sizeof(include));
|
||||
inc = yasm_xmalloc(sizeof(include));
|
||||
inc->include_state = YY_CURRENT_BUFFER;
|
||||
|
||||
/* FIXME: handle includes that aren't relative */
|
||||
|
|
@ -174,7 +177,7 @@ DIR %[ \t]*
|
|||
if(!incfile) {
|
||||
yasm__error(cur_lindex, _("include file `%s': %s"),
|
||||
yytext, strerror(errno));
|
||||
xfree(inc);
|
||||
yasm_xfree(inc);
|
||||
}
|
||||
else {
|
||||
yyin = incfile;
|
||||
|
|
@ -183,7 +186,7 @@ DIR %[ \t]*
|
|||
SLIST_INSERT_HEAD(&includes_head, inc, next);
|
||||
|
||||
yapp_preproc_line_number = 1;
|
||||
yapp_preproc_current_file = xstrdup(yytext);
|
||||
yapp_preproc_current_file = yasm__xstrdup(yytext);
|
||||
BEGIN(INITIAL);
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
||||
}
|
||||
|
|
@ -200,11 +203,11 @@ DIR %[ \t]*
|
|||
inc = SLIST_FIRST(&includes_head);
|
||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer (inc->include_state);
|
||||
xfree(yapp_preproc_current_file);
|
||||
yasm_xfree(yapp_preproc_current_file);
|
||||
yapp_preproc_current_file = inc->filename;
|
||||
yapp_preproc_line_number = inc->line_number + 1;
|
||||
SLIST_REMOVE_HEAD(&includes_head, next);
|
||||
xfree(inc);
|
||||
yasm_xfree(inc);
|
||||
|
||||
BEGIN(incl);
|
||||
return INCLUDE;
|
||||
|
|
@ -228,8 +231,8 @@ DIR %[ \t]*
|
|||
}
|
||||
<line>{WS}+["] ; /* eat space before file */
|
||||
<line>[^ \t\n"]* { /* have the filename */
|
||||
xfree(yapp_preproc_current_file);
|
||||
yapp_preproc_current_file = xstrdup(yytext);
|
||||
yasm_xfree(yapp_preproc_current_file);
|
||||
yapp_preproc_current_file = yasm__xstrdup(yytext);
|
||||
}
|
||||
<line>["]{WS}*\n {
|
||||
BEGIN(INITIAL);
|
||||
|
|
|
|||
10
src/arch.c
10
src/arch.c
|
|
@ -45,7 +45,7 @@ yasm_arch_common_initialize(yasm_arch *a)
|
|||
yasm_insn_operand *
|
||||
yasm_operand_new_reg(unsigned long reg)
|
||||
{
|
||||
yasm_insn_operand *retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
|
||||
retval->type = YASM_INSN__OPERAND_REG;
|
||||
retval->data.reg = reg;
|
||||
|
|
@ -58,7 +58,7 @@ yasm_operand_new_reg(unsigned long reg)
|
|||
yasm_insn_operand *
|
||||
yasm_operand_new_segreg(unsigned long segreg)
|
||||
{
|
||||
yasm_insn_operand *retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
|
||||
retval->type = YASM_INSN__OPERAND_SEGREG;
|
||||
retval->data.reg = segreg;
|
||||
|
|
@ -71,7 +71,7 @@ yasm_operand_new_segreg(unsigned long segreg)
|
|||
yasm_insn_operand *
|
||||
yasm_operand_new_mem(/*@only@*/ yasm_effaddr *ea)
|
||||
{
|
||||
yasm_insn_operand *retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
|
||||
retval->type = YASM_INSN__OPERAND_MEMORY;
|
||||
retval->data.ea = ea;
|
||||
|
|
@ -92,7 +92,7 @@ yasm_operand_new_imm(/*@only@*/ yasm_expr *val)
|
|||
retval = yasm_operand_new_reg(*reg);
|
||||
yasm_expr_delete(val);
|
||||
} else {
|
||||
retval = xmalloc(sizeof(yasm_insn_operand));
|
||||
retval = yasm_xmalloc(sizeof(yasm_insn_operand));
|
||||
retval->type = YASM_INSN__OPERAND_IMM;
|
||||
retval->data.val = val;
|
||||
retval->targetmod = 0;
|
||||
|
|
@ -149,7 +149,7 @@ yasm_ops_delete(yasm_insn_operandhead *headp, int content)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
xfree(cur);
|
||||
yasm_xfree(cur);
|
||||
cur = next;
|
||||
}
|
||||
STAILQ_INIT(headp);
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex, unsigned char bits)
|
|||
if (yasm_x86__set_rex_from_reg(rex, &rm, reg, bits, X86_REX_B))
|
||||
return NULL;
|
||||
|
||||
x86_ea = xmalloc(sizeof(x86_effaddr));
|
||||
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
|
||||
|
||||
x86_ea->ea.disp = (yasm_expr *)NULL;
|
||||
x86_ea->ea.len = 0;
|
||||
|
|
@ -285,7 +285,7 @@ yasm_x86__ea_new_expr(yasm_expr *e)
|
|||
{
|
||||
x86_effaddr *x86_ea;
|
||||
|
||||
x86_ea = xmalloc(sizeof(x86_effaddr));
|
||||
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
|
||||
|
||||
x86_ea->ea.disp = e;
|
||||
x86_ea->ea.len = 0;
|
||||
|
|
@ -310,7 +310,7 @@ yasm_x86__ea_new_imm(yasm_expr *imm, unsigned char im_len)
|
|||
{
|
||||
x86_effaddr *x86_ea;
|
||||
|
||||
x86_ea = xmalloc(sizeof(x86_effaddr));
|
||||
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
|
||||
|
||||
x86_ea->ea.disp = imm;
|
||||
x86_ea->ea.len = im_len;
|
||||
|
|
@ -432,7 +432,7 @@ yasm_x86__bc_delete(yasm_bytecode *bc)
|
|||
yasm_ea_delete((yasm_effaddr *)insn->ea);
|
||||
if (insn->imm) {
|
||||
yasm_expr_delete(insn->imm->val);
|
||||
xfree(insn->imm);
|
||||
yasm_xfree(insn->imm);
|
||||
}
|
||||
break;
|
||||
case X86_BC_JMPREL:
|
||||
|
|
@ -645,7 +645,7 @@ x86_bc_resolve_insn(x86_insn *insn, unsigned long *len, int save,
|
|||
insn->opcode[0] = insn->opcode[1];
|
||||
/* Delete imm, as it's not needed. */
|
||||
yasm_expr_delete(imm->val);
|
||||
xfree(imm);
|
||||
yasm_xfree(imm);
|
||||
insn->imm = (yasm_immval *)NULL;
|
||||
}
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -2071,7 +2071,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
if (d.ea)
|
||||
xfree(d.ea);
|
||||
yasm_xfree(d.ea);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ ErrCode BitVector_Boot(void)
|
|||
FACTOR = LOGBITS - 3; /* ld(BITS / 8) = ld(BITS) - ld(8) = ld(BITS) - 3 */
|
||||
MSB = (LSB << MODMASK);
|
||||
|
||||
BITMASKTAB = (wordptr) xmalloc((size_t) (BITS << FACTOR));
|
||||
BITMASKTAB = (wordptr) yasm_xmalloc((size_t) (BITS << FACTOR));
|
||||
|
||||
if (BITMASKTAB == NULL) return(ErrCode_Null);
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ ErrCode BitVector_Boot(void)
|
|||
|
||||
void BitVector_Shutdown(void)
|
||||
{
|
||||
if (BITMASKTAB) xfree(BITMASKTAB);
|
||||
if (BITMASKTAB) yasm_xfree(BITMASKTAB);
|
||||
}
|
||||
|
||||
N_word BitVector_Size(N_int bits) /* bit vector size (# of words) */
|
||||
|
|
@ -399,7 +399,7 @@ N_int BitVector_Long_Bits(void)
|
|||
|
||||
void BitVector_Dispose(charptr string) /* free string */
|
||||
{
|
||||
if (string != NULL) xfree((voidptr) string);
|
||||
if (string != NULL) yasm_xfree((voidptr) string);
|
||||
}
|
||||
|
||||
void BitVector_Destroy(wordptr addr) /* free bitvec */
|
||||
|
|
@ -407,7 +407,7 @@ void BitVector_Destroy(wordptr addr) /* free bitvec */
|
|||
if (addr != NULL)
|
||||
{
|
||||
addr -= BIT_VECTOR_HIDDEN_WORDS;
|
||||
xfree((voidptr) addr);
|
||||
yasm_xfree((voidptr) addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ wordptr BitVector_Create(N_int bits, boolean clear) /* malloc */
|
|||
size = BitVector_Size(bits);
|
||||
mask = BitVector_Mask(bits);
|
||||
bytes = (size + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
|
||||
addr = (wordptr) xmalloc((size_t) bytes);
|
||||
addr = (wordptr) yasm_xmalloc((size_t) bytes);
|
||||
if (addr != NULL)
|
||||
{
|
||||
*addr++ = bits;
|
||||
|
|
@ -507,7 +507,7 @@ wordptr BitVector_Resize(wordptr oldaddr, N_int bits) /* realloc */
|
|||
else
|
||||
{
|
||||
bytes = (newsize + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
|
||||
newaddr = (wordptr) xmalloc((size_t) bytes);
|
||||
newaddr = (wordptr) yasm_xmalloc((size_t) bytes);
|
||||
if (newaddr != NULL)
|
||||
{
|
||||
*newaddr++ = bits;
|
||||
|
|
@ -1428,7 +1428,7 @@ charptr BitVector_to_Hex(wordptr addr)
|
|||
|
||||
length = bits >> 2;
|
||||
if (bits AND 0x0003) length++;
|
||||
string = (charptr) xmalloc((size_t) (length+1));
|
||||
string = (charptr) yasm_xmalloc((size_t) (length+1));
|
||||
if (string == NULL) return(NULL);
|
||||
string += length;
|
||||
*string = (N_char) '\0';
|
||||
|
|
@ -1540,7 +1540,7 @@ charptr BitVector_to_Bin(wordptr addr)
|
|||
charptr string;
|
||||
|
||||
length = bits_(addr);
|
||||
string = (charptr) xmalloc((size_t) (length+1));
|
||||
string = (charptr) yasm_xmalloc((size_t) (length+1));
|
||||
if (string == NULL) return(NULL);
|
||||
string += length;
|
||||
*string = (N_char) '\0';
|
||||
|
|
@ -1623,7 +1623,7 @@ charptr BitVector_to_Dec(wordptr addr)
|
|||
|
||||
length = (N_word) (bits / 3.3); /* digits = bits * ln(2) / ln(10) */
|
||||
length += 2; /* compensate for truncating & provide space for minus sign */
|
||||
result = (charptr) xmalloc((size_t) (length+1)); /* remember the '\0'! */
|
||||
result = (charptr) yasm_xmalloc((size_t) (length+1)); /* remember the '\0'! */
|
||||
if (result == NULL) return(NULL);
|
||||
string = result;
|
||||
sign = BitVector_Sign(addr);
|
||||
|
|
@ -2064,7 +2064,7 @@ charptr BitVector_to_Enum(wordptr addr)
|
|||
}
|
||||
}
|
||||
else length = 1;
|
||||
string = (charptr) xmalloc((size_t) length);
|
||||
string = (charptr) yasm_xmalloc((size_t) length);
|
||||
if (string == NULL) return(NULL);
|
||||
start = 0;
|
||||
comma = FALSE;
|
||||
|
|
@ -3247,7 +3247,7 @@ charptr BitVector_Block_Read(wordptr addr, N_intptr length)
|
|||
|
||||
/* provide translation for independence of endian-ness: */
|
||||
*length = size << FACTOR;
|
||||
buffer = (charptr) xmalloc((size_t) ((*length)+1));
|
||||
buffer = (charptr) yasm_xmalloc((size_t) ((*length)+1));
|
||||
if (buffer == NULL) return(NULL);
|
||||
target = buffer;
|
||||
if (size > 0)
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ yasm_imm_new_int(unsigned long int_val, unsigned long lindex)
|
|||
yasm_immval *
|
||||
yasm_imm_new_expr(yasm_expr *expr_ptr)
|
||||
{
|
||||
yasm_immval *im = xmalloc(sizeof(yasm_immval));
|
||||
yasm_immval *im = yasm_xmalloc(sizeof(yasm_immval));
|
||||
|
||||
im->val = expr_ptr;
|
||||
im->len = 0;
|
||||
|
|
@ -164,7 +164,7 @@ yasm_ea_delete(yasm_effaddr *ea)
|
|||
if (cur_arch->ea_data_delete)
|
||||
cur_arch->ea_data_delete(ea);
|
||||
yasm_expr_delete(ea->disp);
|
||||
xfree(ea);
|
||||
yasm_xfree(ea);
|
||||
}
|
||||
/*@=nullstate@*/
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ yasm_bc_set_multiple(yasm_bytecode *bc, yasm_expr *e)
|
|||
yasm_bytecode *
|
||||
yasm_bc_new_common(yasm_bytecode_type type, size_t size, unsigned long lindex)
|
||||
{
|
||||
yasm_bytecode *bc = xmalloc(size);
|
||||
yasm_bytecode *bc = yasm_xmalloc(size);
|
||||
|
||||
bc->type = type;
|
||||
|
||||
|
|
@ -323,7 +323,7 @@ yasm_bc_delete(yasm_bytecode *bc)
|
|||
break;
|
||||
case YASM_BC__INCBIN:
|
||||
incbin = (bytecode_incbin *)bc;
|
||||
xfree(incbin->filename);
|
||||
yasm_xfree(incbin->filename);
|
||||
yasm_expr_delete(incbin->start);
|
||||
yasm_expr_delete(incbin->maxlen);
|
||||
break;
|
||||
|
|
@ -348,7 +348,7 @@ yasm_bc_delete(yasm_bytecode *bc)
|
|||
/*@=branchstate@*/
|
||||
|
||||
yasm_expr_delete(bc->multiple);
|
||||
xfree(bc);
|
||||
yasm_xfree(bc);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -799,7 +799,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
*gap = 0;
|
||||
|
||||
if (*bufsize < datasize) {
|
||||
mybuf = xmalloc(sizeof(bc->len));
|
||||
mybuf = yasm_xmalloc(sizeof(bc->len));
|
||||
origbuf = mybuf;
|
||||
destbuf = mybuf;
|
||||
} else {
|
||||
|
|
@ -874,7 +874,7 @@ yasm_bcs_append(yasm_bytecodehead *headp, yasm_bytecode *bc)
|
|||
STAILQ_INSERT_TAIL(headp, bc, link);
|
||||
return bc;
|
||||
} else {
|
||||
xfree(bc);
|
||||
yasm_xfree(bc);
|
||||
}
|
||||
}
|
||||
return (yasm_bytecode *)NULL;
|
||||
|
|
@ -908,7 +908,7 @@ yasm_bcs_traverse(yasm_bytecodehead *headp, void *d,
|
|||
yasm_dataval *
|
||||
yasm_dv_new_expr(yasm_expr *expn)
|
||||
{
|
||||
yasm_dataval *retval = xmalloc(sizeof(yasm_dataval));
|
||||
yasm_dataval *retval = yasm_xmalloc(sizeof(yasm_dataval));
|
||||
|
||||
retval->type = DV_EXPR;
|
||||
retval->data.expn = expn;
|
||||
|
|
@ -919,7 +919,7 @@ yasm_dv_new_expr(yasm_expr *expn)
|
|||
yasm_dataval *
|
||||
yasm_dv_new_string(char *str_val)
|
||||
{
|
||||
yasm_dataval *retval = xmalloc(sizeof(yasm_dataval));
|
||||
yasm_dataval *retval = yasm_xmalloc(sizeof(yasm_dataval));
|
||||
|
||||
retval->type = DV_STRING;
|
||||
retval->data.str_val = str_val;
|
||||
|
|
@ -940,12 +940,12 @@ yasm_dvs_delete(yasm_datavalhead *headp)
|
|||
yasm_expr_delete(cur->data.expn);
|
||||
break;
|
||||
case DV_STRING:
|
||||
xfree(cur->data.str_val);
|
||||
yasm_xfree(cur->data.str_val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xfree(cur);
|
||||
yasm_xfree(cur);
|
||||
cur = next;
|
||||
}
|
||||
STAILQ_INIT(headp);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ yasm_errwarn_cleanup(void)
|
|||
we = SLIST_FIRST(&errwarns);
|
||||
|
||||
SLIST_REMOVE_HEAD(&errwarns, link);
|
||||
xfree(we);
|
||||
yasm_xfree(we);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
|
|||
we = ins_we;
|
||||
} else {
|
||||
/* add a new error */
|
||||
we = xmalloc(sizeof(errwarn_data));
|
||||
we = yasm_xmalloc(sizeof(errwarn_data));
|
||||
|
||||
we->type = WE_UNKNOWN;
|
||||
we->line = lindex;
|
||||
|
|
|
|||
48
src/expr.c
48
src/expr.c
|
|
@ -65,7 +65,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
unsigned long lindex)
|
||||
{
|
||||
yasm_expr *ptr, *sube;
|
||||
ptr = xmalloc(sizeof(yasm_expr));
|
||||
ptr = yasm_xmalloc(sizeof(yasm_expr));
|
||||
|
||||
ptr->op = op;
|
||||
ptr->numterms = 0;
|
||||
|
|
@ -73,7 +73,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
ptr->terms[1].type = YASM_EXPR_NONE;
|
||||
if (left) {
|
||||
ptr->terms[0] = *left; /* structure copy */
|
||||
xfree(left);
|
||||
yasm_xfree(left);
|
||||
ptr->numterms++;
|
||||
|
||||
/* Search downward until we find something *other* than an
|
||||
|
|
@ -84,7 +84,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
sube = ptr->terms[0].data.expn;
|
||||
ptr->terms[0] = sube->terms[0]; /* structure copy */
|
||||
/*@-usereleased@*/
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
} else {
|
||||
|
|
@ -93,7 +93,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
|
||||
if (right) {
|
||||
ptr->terms[1] = *right; /* structure copy */
|
||||
xfree(right);
|
||||
yasm_xfree(right);
|
||||
ptr->numterms++;
|
||||
|
||||
/* Search downward until we find something *other* than an
|
||||
|
|
@ -104,7 +104,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
sube = ptr->terms[1].data.expn;
|
||||
ptr->terms[1] = sube->terms[0]; /* structure copy */
|
||||
/*@-usereleased@*/
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
yasm_expr__item *
|
||||
yasm_expr_sym(yasm_symrec *s)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_SYM;
|
||||
e->data.sym = s;
|
||||
return e;
|
||||
|
|
@ -128,7 +128,7 @@ yasm_expr_sym(yasm_symrec *s)
|
|||
yasm_expr__item *
|
||||
yasm_expr_expr(yasm_expr *x)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_EXPR;
|
||||
e->data.expn = x;
|
||||
return e;
|
||||
|
|
@ -137,7 +137,7 @@ yasm_expr_expr(yasm_expr *x)
|
|||
yasm_expr__item *
|
||||
yasm_expr_int(yasm_intnum *i)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_INT;
|
||||
e->data.intn = i;
|
||||
return e;
|
||||
|
|
@ -146,7 +146,7 @@ yasm_expr_int(yasm_intnum *i)
|
|||
yasm_expr__item *
|
||||
yasm_expr_float(yasm_floatnum *f)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_FLOAT;
|
||||
e->data.flt = f;
|
||||
return e;
|
||||
|
|
@ -155,7 +155,7 @@ yasm_expr_float(yasm_floatnum *f)
|
|||
yasm_expr__item *
|
||||
yasm_expr_reg(unsigned long reg)
|
||||
{
|
||||
yasm_expr__item *e = xmalloc(sizeof(yasm_expr__item));
|
||||
yasm_expr__item *e = yasm_xmalloc(sizeof(yasm_expr__item));
|
||||
e->type = YASM_EXPR_REG;
|
||||
e->data.reg = reg;
|
||||
return e;
|
||||
|
|
@ -254,8 +254,8 @@ expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e,
|
|||
}
|
||||
if (e->numterms != numterms) {
|
||||
e->numterms = numterms;
|
||||
e = xrealloc(e, sizeof(yasm_expr)+((numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(numterms-2)));
|
||||
e = yasm_xrealloc(e, sizeof(yasm_expr)+((numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(numterms-2)));
|
||||
if (numterms == 1)
|
||||
e->op = YASM_EXPR_IDENT;
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e,
|
|||
static void
|
||||
expr_xform_neg_item(yasm_expr *e, yasm_expr__item *ei)
|
||||
{
|
||||
yasm_expr *sube = xmalloc(sizeof(yasm_expr));
|
||||
yasm_expr *sube = yasm_xmalloc(sizeof(yasm_expr));
|
||||
|
||||
/* Build -1*ei subexpression */
|
||||
sube->op = YASM_EXPR_MUL;
|
||||
|
|
@ -339,7 +339,7 @@ expr_xform_neg_helper(/*@returned@*/ /*@only@*/ yasm_expr *e)
|
|||
/* Everything else. MUL will be combined when it's leveled.
|
||||
* Make a new expr (to replace e) with -1*e.
|
||||
*/
|
||||
ne = xmalloc(sizeof(yasm_expr));
|
||||
ne = yasm_xmalloc(sizeof(yasm_expr));
|
||||
ne->op = YASM_EXPR_MUL;
|
||||
ne->line = e->line;
|
||||
ne->numterms = 2;
|
||||
|
|
@ -514,7 +514,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
*/
|
||||
while (e->op == YASM_EXPR_IDENT && e->terms[0].type == YASM_EXPR_EXPR) {
|
||||
yasm_expr *sube = e->terms[0].data.expn;
|
||||
xfree(e);
|
||||
yasm_xfree(e);
|
||||
e = sube;
|
||||
}
|
||||
level_numterms = e->numterms;
|
||||
|
|
@ -527,7 +527,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
e->terms[i].data.expn->op == YASM_EXPR_IDENT) {
|
||||
yasm_expr *sube = e->terms[i].data.expn;
|
||||
e->terms[i] = sube->terms[0];
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
}
|
||||
|
||||
if (e->terms[i].type == YASM_EXPR_EXPR &&
|
||||
|
|
@ -592,8 +592,8 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
level_numterms <= fold_numterms) {
|
||||
/* Downsize e if necessary */
|
||||
if (fold_numterms < e->numterms && e->numterms > 2)
|
||||
e = xrealloc(e, sizeof(yasm_expr)+((fold_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(fold_numterms-2)));
|
||||
e = yasm_xrealloc(e, sizeof(yasm_expr)+((fold_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(fold_numterms-2)));
|
||||
/* Update numterms */
|
||||
e->numterms = fold_numterms;
|
||||
return e;
|
||||
|
|
@ -609,8 +609,8 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
}
|
||||
|
||||
/* Alloc more (or conceivably less, but not usually) space for e */
|
||||
e = xrealloc(e, sizeof(yasm_expr)+((level_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(level_numterms-2)));
|
||||
e = yasm_xrealloc(e, sizeof(yasm_expr)+((level_numterms<2) ? 0 :
|
||||
sizeof(yasm_expr__item)*(level_numterms-2)));
|
||||
|
||||
/* Copy up ExprItem's. Iterate from right to left to keep the same
|
||||
* ordering as was present originally.
|
||||
|
|
@ -647,7 +647,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
|
|||
/* delete subexpression, but *don't delete nodes* (as we've just
|
||||
* copied them!)
|
||||
*/
|
||||
xfree(sube);
|
||||
yasm_xfree(sube);
|
||||
} else if (o != i) {
|
||||
/* copy operand if it changed places */
|
||||
if (o == first_int_term)
|
||||
|
|
@ -804,8 +804,8 @@ yasm_expr__copy_except(const yasm_expr *e, int except)
|
|||
yasm_expr *n;
|
||||
int i;
|
||||
|
||||
n = xmalloc(sizeof(yasm_expr) +
|
||||
sizeof(yasm_expr__item)*(e->numterms<2?0:e->numterms-2));
|
||||
n = yasm_xmalloc(sizeof(yasm_expr) +
|
||||
sizeof(yasm_expr__item)*(e->numterms<2?0:e->numterms-2));
|
||||
|
||||
n->op = e->op;
|
||||
n->line = e->line;
|
||||
|
|
@ -865,7 +865,7 @@ expr_delete_each(/*@only@*/ yasm_expr *e, /*@unused@*/ void *d)
|
|||
break; /* none of the other types needs to be deleted */
|
||||
}
|
||||
}
|
||||
xfree(e); /* free ourselves */
|
||||
yasm_xfree(e); /* free ourselves */
|
||||
return 0; /* don't stop recursion */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,8 +166,8 @@ yasm_floatnum_initialize(void)
|
|||
int i;
|
||||
|
||||
/* Allocate space for two POT tables */
|
||||
POT_TableN = xmalloc(14*sizeof(POT_Entry));
|
||||
POT_TableP = xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
|
||||
POT_TableN = yasm_xmalloc(14*sizeof(POT_Entry));
|
||||
POT_TableP = yasm_xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
|
||||
|
||||
/* Initialize entry[0..12] */
|
||||
for (i=12; i>=0; i--) {
|
||||
|
|
@ -203,8 +203,8 @@ yasm_floatnum_cleanup(void)
|
|||
}
|
||||
BitVector_Destroy(POT_TableP[14].f.mantissa);
|
||||
|
||||
xfree(POT_TableN);
|
||||
xfree(POT_TableP);
|
||||
yasm_xfree(POT_TableN);
|
||||
yasm_xfree(POT_TableP);
|
||||
}
|
||||
/*@=globstate@*/
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ yasm_floatnum_new(const char *str)
|
|||
int decimal_pt;
|
||||
boolean carry;
|
||||
|
||||
flt = xmalloc(sizeof(yasm_floatnum));
|
||||
flt = yasm_xmalloc(sizeof(yasm_floatnum));
|
||||
|
||||
flt->mantissa = BitVector_Create(MANT_BITS, TRUE);
|
||||
|
||||
|
|
@ -490,7 +490,7 @@ yasm_floatnum_new(const char *str)
|
|||
yasm_floatnum *
|
||||
yasm_floatnum_copy(const yasm_floatnum *flt)
|
||||
{
|
||||
yasm_floatnum *f = xmalloc(sizeof(yasm_floatnum));
|
||||
yasm_floatnum *f = yasm_xmalloc(sizeof(yasm_floatnum));
|
||||
|
||||
f->mantissa = BitVector_Clone(flt->mantissa);
|
||||
f->exponent = flt->exponent;
|
||||
|
|
@ -504,7 +504,7 @@ void
|
|||
yasm_floatnum_delete(yasm_floatnum *flt)
|
||||
{
|
||||
BitVector_Destroy(flt->mantissa);
|
||||
xfree(flt);
|
||||
yasm_xfree(flt);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -618,7 +618,7 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr,
|
|||
memcpy(ptr, buf, byte_size*sizeof(unsigned char));
|
||||
|
||||
/* free allocated resources */
|
||||
xfree(buf);
|
||||
yasm_xfree(buf);
|
||||
|
||||
BitVector_Destroy(output);
|
||||
|
||||
|
|
@ -698,7 +698,7 @@ yasm_floatnum_print(FILE *f, const yasm_floatnum *flt)
|
|||
str = BitVector_to_Hex(flt->mantissa);
|
||||
fprintf(f, "%c %s *2^%04x\n", flt->sign?'-':'+', (char *)str,
|
||||
flt->exponent);
|
||||
xfree(str);
|
||||
yasm_xfree(str);
|
||||
|
||||
/* 32-bit (single precision) format */
|
||||
fprintf(f, "32-bit: %d: ", yasm_floatnum_get_sized(flt, out, 4));
|
||||
|
|
|
|||
26
src/hamt.c
26
src/hamt.c
|
|
@ -87,11 +87,11 @@ HAMT *
|
|||
HAMT_new(/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message))
|
||||
{
|
||||
/*@out@*/ HAMT *hamt = xmalloc(sizeof(HAMT));
|
||||
/*@out@*/ HAMT *hamt = yasm_xmalloc(sizeof(HAMT));
|
||||
int i;
|
||||
|
||||
SLIST_INIT(&hamt->entries);
|
||||
hamt->root = xmalloc(32*sizeof(HAMTNode));
|
||||
hamt->root = yasm_xmalloc(32*sizeof(HAMTNode));
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
hamt->root[i].BitMapKey = 0;
|
||||
|
|
@ -115,7 +115,7 @@ HAMT_delete_trie(HAMTNode *node)
|
|||
|
||||
for (i=0; i<Size; i++)
|
||||
HAMT_delete_trie(&(GetSubTrie(node))[i]);
|
||||
xfree(GetSubTrie(node));
|
||||
yasm_xfree(GetSubTrie(node));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,15 +130,15 @@ HAMT_delete(HAMT *hamt, void (*deletefunc) (/*@only@*/ void *data))
|
|||
entry = SLIST_FIRST(&hamt->entries);
|
||||
SLIST_REMOVE_HEAD(&hamt->entries, next);
|
||||
deletefunc(entry->data);
|
||||
xfree(entry);
|
||||
yasm_xfree(entry);
|
||||
}
|
||||
|
||||
/* delete trie */
|
||||
for (i=0; i<32; i++)
|
||||
HAMT_delete_trie(&hamt->root[i]);
|
||||
|
||||
xfree(hamt->root);
|
||||
xfree(hamt);
|
||||
yasm_xfree(hamt->root);
|
||||
yasm_xfree(hamt);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -170,7 +170,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
|
||||
if (!node->BaseValue) {
|
||||
node->BitMapKey = key;
|
||||
entry = xmalloc(sizeof(HAMTEntry));
|
||||
entry = yasm_xmalloc(sizeof(HAMTEntry));
|
||||
entry->str = str;
|
||||
entry->data = data;
|
||||
SLIST_INSERT_HEAD(&hamt->entries, entry, next);
|
||||
|
|
@ -216,7 +216,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
/* Still equal, build one-node subtrie and continue
|
||||
* downward.
|
||||
*/
|
||||
newnodes = xmalloc(sizeof(HAMTNode));
|
||||
newnodes = yasm_xmalloc(sizeof(HAMTNode));
|
||||
newnodes[0] = *node; /* structure copy */
|
||||
node->BitMapKey = 1<<keypart;
|
||||
SetSubTrie(hamt, node, newnodes);
|
||||
|
|
@ -224,9 +224,9 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
level++;
|
||||
} else {
|
||||
/* partitioned: allocate two-node subtrie */
|
||||
newnodes = xmalloc(2*sizeof(HAMTNode));
|
||||
newnodes = yasm_xmalloc(2*sizeof(HAMTNode));
|
||||
|
||||
entry = xmalloc(sizeof(HAMTEntry));
|
||||
entry = yasm_xmalloc(sizeof(HAMTEntry));
|
||||
entry->str = str;
|
||||
entry->data = data;
|
||||
SLIST_INSERT_HEAD(&hamt->entries, entry, next);
|
||||
|
|
@ -270,7 +270,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
/* Count total number of bits in bitmap to determine new size */
|
||||
BitCount(Size, node->BitMapKey);
|
||||
Size &= 0x1F; /* Clamp to <32 */
|
||||
newnodes = xmalloc(Size*sizeof(HAMTNode));
|
||||
newnodes = yasm_xmalloc(Size*sizeof(HAMTNode));
|
||||
|
||||
/* Count bits below to find where to insert new node at */
|
||||
BitCount(Map, node->BitMapKey & ~((~0UL)<<keypart));
|
||||
|
|
@ -280,10 +280,10 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
|
|||
memcpy(&newnodes[Map+1], &(GetSubTrie(node))[Map],
|
||||
(Size-Map-1)*sizeof(HAMTNode));
|
||||
/* Delete old subtrie */
|
||||
xfree(GetSubTrie(node));
|
||||
yasm_xfree(GetSubTrie(node));
|
||||
/* Set up new node */
|
||||
newnodes[Map].BitMapKey = key;
|
||||
entry = xmalloc(sizeof(HAMTEntry));
|
||||
entry = yasm_xmalloc(sizeof(HAMTEntry));
|
||||
entry->str = str;
|
||||
entry->data = data;
|
||||
SLIST_INSERT_HEAD(&hamt->entries, entry, next);
|
||||
|
|
|
|||
20
src/intnum.c
20
src/intnum.c
|
|
@ -68,7 +68,7 @@ yasm_intnum_cleanup(void)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_dec(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = 0; /* no reliable way to figure this out */
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ yasm_intnum_new_dec(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_bin(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = (unsigned char)strlen(str);
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ yasm_intnum_new_bin(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_oct(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = strlen(str)*3;
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ yasm_intnum_new_oct(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_hex(char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->origsize = strlen(str)*4;
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ yasm_intnum_new_hex(char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_charconst_nasm(const char *str, unsigned long lindex)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
size_t len = strlen(str);
|
||||
|
||||
if (len > 4)
|
||||
|
|
@ -195,7 +195,7 @@ yasm_intnum_new_charconst_nasm(const char *str, unsigned long lindex)
|
|||
yasm_intnum *
|
||||
yasm_intnum_new_uint(unsigned long i)
|
||||
{
|
||||
yasm_intnum *intn = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
intn->val.ul = i;
|
||||
intn->type = INTNUM_UL;
|
||||
|
|
@ -214,7 +214,7 @@ yasm_intnum_new_int(long i)
|
|||
yasm_intnum *
|
||||
yasm_intnum_copy(const yasm_intnum *intn)
|
||||
{
|
||||
yasm_intnum *n = xmalloc(sizeof(yasm_intnum));
|
||||
yasm_intnum *n = yasm_xmalloc(sizeof(yasm_intnum));
|
||||
|
||||
switch (intn->type) {
|
||||
case INTNUM_UL:
|
||||
|
|
@ -235,7 +235,7 @@ yasm_intnum_delete(yasm_intnum *intn)
|
|||
{
|
||||
if (intn->type == INTNUM_BV)
|
||||
BitVector_Destroy(intn->val.bv);
|
||||
xfree(intn);
|
||||
yasm_xfree(intn);
|
||||
}
|
||||
|
||||
/*@-nullderef -nullpass -branchstate@*/
|
||||
|
|
@ -561,7 +561,7 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, size_t size)
|
|||
if (len < (unsigned int)size)
|
||||
yasm_internal_error(N_("Invalid size specified (too large)"));
|
||||
memcpy(ptr, buf, size);
|
||||
xfree(buf);
|
||||
yasm_xfree(buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -644,7 +644,7 @@ yasm_intnum_print(FILE *f, const yasm_intnum *intn)
|
|||
case INTNUM_BV:
|
||||
s = BitVector_to_Hex(intn->val.bv);
|
||||
fprintf(f, "0x%s/%u", (char *)s, (unsigned int)intn->origsize);
|
||||
xfree(s);
|
||||
yasm_xfree(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ static line_index_assoc_data_raw_head *line_index_assoc_data_array;
|
|||
static void
|
||||
filename_delete_one(/*@only@*/ void *d)
|
||||
{
|
||||
xfree(d);
|
||||
yasm_xfree(d);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -95,8 +95,9 @@ yasm_std_linemgr_set(const char *filename, unsigned long line,
|
|||
/* Create a new mapping in the map */
|
||||
if (line_index_map->size >= line_index_map->allocated) {
|
||||
/* allocate another size bins when full for 2x space */
|
||||
line_index_map->vector = xrealloc(line_index_map->vector,
|
||||
2*line_index_map->allocated*sizeof(line_index_mapping));
|
||||
line_index_map->vector =
|
||||
yasm_xrealloc(line_index_map->vector, 2*line_index_map->allocated
|
||||
*sizeof(line_index_mapping));
|
||||
line_index_map->allocated *= 2;
|
||||
}
|
||||
mapping = &line_index_map->vector[line_index_map->size];
|
||||
|
|
@ -105,7 +106,7 @@ yasm_std_linemgr_set(const char *filename, unsigned long line,
|
|||
/* Fill it */
|
||||
|
||||
/* Copy the filename (via shared storage) */
|
||||
copy = xstrdup(filename);
|
||||
copy = yasm__xstrdup(filename);
|
||||
/*@-aliasunique@*/
|
||||
mapping->filename = HAMT_insert(filename_table, copy, copy, &replace,
|
||||
filename_delete_one);
|
||||
|
|
@ -126,15 +127,15 @@ yasm_std_linemgr_initialize(void)
|
|||
line_index = 1;
|
||||
|
||||
/* initialize mapping vector */
|
||||
line_index_map = xmalloc(sizeof(line_index_mapping_head));
|
||||
line_index_map->vector = xmalloc(8*sizeof(line_index_mapping));
|
||||
line_index_map = yasm_xmalloc(sizeof(line_index_mapping_head));
|
||||
line_index_map->vector = yasm_xmalloc(8*sizeof(line_index_mapping));
|
||||
line_index_map->size = 0;
|
||||
line_index_map->allocated = 8;
|
||||
|
||||
/* initialize associated data arrays */
|
||||
line_index_assoc_data_array =
|
||||
xmalloc(MAX_LINE_INDEX_ASSOC_DATA_ARRAY *
|
||||
sizeof(line_index_assoc_data_raw_head));
|
||||
yasm_xmalloc(MAX_LINE_INDEX_ASSOC_DATA_ARRAY *
|
||||
sizeof(line_index_assoc_data_raw_head));
|
||||
for (i=0; i<MAX_LINE_INDEX_ASSOC_DATA_ARRAY; i++) {
|
||||
line_index_assoc_data_array[i].vector = NULL;
|
||||
line_index_assoc_data_array[i].size = 0;
|
||||
|
|
@ -155,16 +156,16 @@ yasm_std_linemgr_cleanup(void)
|
|||
if (adrh->vector[j])
|
||||
adrh->delete_func(adrh->vector[j]);
|
||||
}
|
||||
xfree(adrh->vector);
|
||||
yasm_xfree(adrh->vector);
|
||||
}
|
||||
}
|
||||
xfree(line_index_assoc_data_array);
|
||||
yasm_xfree(line_index_assoc_data_array);
|
||||
line_index_assoc_data_array = NULL;
|
||||
}
|
||||
|
||||
if (line_index_map) {
|
||||
xfree(line_index_map->vector);
|
||||
xfree(line_index_map);
|
||||
yasm_xfree(line_index_map->vector);
|
||||
yasm_xfree(line_index_map);
|
||||
line_index_map = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +193,7 @@ yasm_std_linemgr_add_assoc_data(int type, /*@only@*/ void *data,
|
|||
int i;
|
||||
|
||||
adrh->size = 4;
|
||||
adrh->vector = xmalloc(adrh->size*sizeof(void *));
|
||||
adrh->vector = yasm_xmalloc(adrh->size*sizeof(void *));
|
||||
adrh->delete_func = delete_func;
|
||||
for (i=0; i<adrh->size; i++)
|
||||
adrh->vector[i] = NULL;
|
||||
|
|
@ -202,7 +203,8 @@ yasm_std_linemgr_add_assoc_data(int type, /*@only@*/ void *data,
|
|||
int i;
|
||||
|
||||
/* allocate another size bins when full for 2x space */
|
||||
adrh->vector = xrealloc(adrh->vector, 2*adrh->size*sizeof(void *));
|
||||
adrh->vector = yasm_xrealloc(adrh->vector,
|
||||
2*adrh->size*sizeof(void *));
|
||||
for(i=adrh->size; i<adrh->size*2; i++)
|
||||
adrh->vector[i] = NULL;
|
||||
adrh->size *= 2;
|
||||
|
|
|
|||
34
src/main.c
34
src/main.c
|
|
@ -173,8 +173,8 @@ main(int argc, char *argv[])
|
|||
lt_dlmalloc = malloc;
|
||||
lt_dlfree = free;
|
||||
#else
|
||||
lt_dlmalloc = xmalloc;
|
||||
lt_dlfree = xfree;
|
||||
lt_dlmalloc = yasm_xmalloc;
|
||||
lt_dlfree = yasm_xfree;
|
||||
#endif
|
||||
|
||||
/* Initialize preloaded symbol lookup table. */
|
||||
|
|
@ -219,16 +219,16 @@ main(int argc, char *argv[])
|
|||
in = fopen(in_filename, "rt");
|
||||
if (!in) {
|
||||
print_error(_("could not open file `%s'"), in_filename);
|
||||
xfree(in_filename);
|
||||
yasm_xfree(in_filename);
|
||||
if (obj_filename)
|
||||
xfree(obj_filename);
|
||||
yasm_xfree(obj_filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
/* If no files were specified or filename was "-", read stdin */
|
||||
in = stdin;
|
||||
if (!in_filename)
|
||||
in_filename = xstrdup("-");
|
||||
in_filename = yasm__xstrdup("-");
|
||||
}
|
||||
|
||||
/* Initialize line manager */
|
||||
|
|
@ -244,7 +244,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* handle preproc-only case here */
|
||||
if (preproc_only) {
|
||||
char *preproc_buf = xmalloc(PREPROC_BUF_SIZE);
|
||||
char *preproc_buf = yasm_xmalloc(PREPROC_BUF_SIZE);
|
||||
size_t got;
|
||||
|
||||
/* Default output to stdout if not specified */
|
||||
|
|
@ -254,7 +254,7 @@ main(int argc, char *argv[])
|
|||
/* Open output (object) file */
|
||||
obj = open_obj("wt");
|
||||
if (!obj) {
|
||||
xfree(preproc_buf);
|
||||
yasm_xfree(preproc_buf);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
@ -285,11 +285,11 @@ main(int argc, char *argv[])
|
|||
print_yasm_error, print_yasm_warning);
|
||||
if (obj != stdout)
|
||||
remove(obj_filename);
|
||||
xfree(preproc_buf);
|
||||
yasm_xfree(preproc_buf);
|
||||
cleanup(NULL);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
xfree(preproc_buf);
|
||||
yasm_xfree(preproc_buf);
|
||||
cleanup(NULL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ main(int argc, char *argv[])
|
|||
if (!obj_filename) {
|
||||
if (in == stdin)
|
||||
/* Default to yasm.out if no obj filename specified */
|
||||
obj_filename = xstrdup("yasm.out");
|
||||
obj_filename = yasm__xstrdup("yasm.out");
|
||||
else
|
||||
/* replace (or add) extension */
|
||||
obj_filename = replace_extension(in_filename,
|
||||
|
|
@ -521,9 +521,9 @@ cleanup(yasm_sectionhead *sections)
|
|||
|
||||
if (DO_FREE) {
|
||||
if (in_filename)
|
||||
xfree(in_filename);
|
||||
yasm_xfree(in_filename);
|
||||
if (obj_filename)
|
||||
xfree(obj_filename);
|
||||
yasm_xfree(obj_filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -536,10 +536,10 @@ not_an_option_handler(char *param)
|
|||
if (in_filename) {
|
||||
print_error(
|
||||
_("warning: can open only one input file, only the last file will be processed"));
|
||||
xfree(in_filename);
|
||||
yasm_xfree(in_filename);
|
||||
}
|
||||
|
||||
in_filename = xstrdup(param);
|
||||
in_filename = yasm__xstrdup(param);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -607,11 +607,11 @@ opt_objfile_handler(/*@unused@*/ char *cmd, char *param,
|
|||
if (obj_filename) {
|
||||
print_error(
|
||||
_("warning: can output to only one object file, last specified used"));
|
||||
xfree(obj_filename);
|
||||
yasm_xfree(obj_filename);
|
||||
}
|
||||
|
||||
assert(param != NULL);
|
||||
obj_filename = xstrdup(param);
|
||||
obj_filename = yasm__xstrdup(param);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -673,7 +673,7 @@ replace_extension(const char *orig, /*@null@*/ const char *ext,
|
|||
char *out, *outext;
|
||||
|
||||
/* allocate enough space for full existing name + extension */
|
||||
out = xmalloc(strlen(orig)+(ext ? (strlen(ext)+2) : 1));
|
||||
out = yasm_xmalloc(strlen(orig)+(ext ? (strlen(ext)+2) : 1));
|
||||
strcpy(out, orig);
|
||||
outext = strrchr(out, '.');
|
||||
if (outext) {
|
||||
|
|
|
|||
10
src/module.c
10
src/module.c
|
|
@ -79,17 +79,17 @@ load_module(const char *keyword)
|
|||
}
|
||||
|
||||
/* Look for dynamic module. First build full module name from keyword. */
|
||||
name = xmalloc(5+strlen(keyword)+1);
|
||||
name = yasm_xmalloc(5+strlen(keyword)+1);
|
||||
strcpy(name, "yasm-");
|
||||
strcat(name, keyword);
|
||||
handle = lt_dlopenext(name);
|
||||
|
||||
if (!handle) {
|
||||
xfree(name);
|
||||
yasm_xfree(name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m = xmalloc(sizeof(module));
|
||||
m = yasm_xmalloc(sizeof(module));
|
||||
m->keyword = name;
|
||||
strcpy(m->keyword, keyword);
|
||||
m->handle = handle;
|
||||
|
|
@ -105,9 +105,9 @@ unload_modules(void)
|
|||
while (!SLIST_EMPTY(&modules)) {
|
||||
m = SLIST_FIRST(&modules);
|
||||
SLIST_REMOVE_HEAD(&modules, link);
|
||||
xfree(m->keyword);
|
||||
yasm_xfree(m->keyword);
|
||||
lt_dlclose(m->handle);
|
||||
xfree(m);
|
||||
yasm_xfree(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Don't bother doing anything else if size ended up being 0. */
|
||||
if (size == 0) {
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
|
||||
/* If bigbuf was allocated, free it */
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
bin_objfmt_output_info info;
|
||||
|
||||
info.f = f;
|
||||
info.buf = xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
|
||||
text = yasm_sections_find_general(sections, ".text");
|
||||
data = yasm_sections_find_general(sections, ".data");
|
||||
|
|
@ -311,7 +311,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
/* If .bss is present, check it for non-reserve bytecodes */
|
||||
|
||||
|
||||
xfree(info.buf);
|
||||
yasm_xfree(info.buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -396,7 +396,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
if (isnew) {
|
||||
if (have_alignval) {
|
||||
unsigned long *data = xmalloc(sizeof(unsigned long));
|
||||
unsigned long *data = yasm_xmalloc(sizeof(unsigned long));
|
||||
*data = alignval;
|
||||
yasm_section_set_of_data(retval, &yasm_bin_LTX_objfmt, data);
|
||||
}
|
||||
|
|
@ -415,7 +415,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
static void
|
||||
bin_objfmt_section_data_delete(/*@only@*/ void *d)
|
||||
{
|
||||
xfree(d);
|
||||
yasm_xfree(d);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -180,14 +180,14 @@ coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass,
|
|||
sym_data_prev = yasm_symrec_get_of_data(entry->sym);
|
||||
assert(sym_data_prev != NULL);
|
||||
|
||||
sym_data = xmalloc(sizeof(coff_symrec_data));
|
||||
sym_data = yasm_xmalloc(sizeof(coff_symrec_data));
|
||||
sym_data->index = sym_data_prev->index + entry->numaux + 1;
|
||||
sym_data->sclass = sclass;
|
||||
sym_data->size = size;
|
||||
yasm_symrec_set_of_data(sym, &yasm_coff_LTX_objfmt, sym_data);
|
||||
|
||||
entry = xmalloc(sizeof(coff_symtab_entry) +
|
||||
(numaux-1)*sizeof(coff_symtab_auxent));
|
||||
entry = yasm_xmalloc(sizeof(coff_symtab_entry) +
|
||||
(numaux-1)*sizeof(coff_symtab_auxent));
|
||||
entry->sym = sym;
|
||||
entry->numaux = numaux;
|
||||
entry->auxtype = auxtype;
|
||||
|
|
@ -210,18 +210,18 @@ coff_objfmt_initialize(const char *in_filename,
|
|||
coff_objfmt_parse_scnum = 1; /* section numbering starts at 1 */
|
||||
STAILQ_INIT(&coff_symtab);
|
||||
|
||||
data = xmalloc(sizeof(coff_symrec_data));
|
||||
data = yasm_xmalloc(sizeof(coff_symrec_data));
|
||||
data->index = 0;
|
||||
data->sclass = COFF_SCL_FILE;
|
||||
data->size = NULL;
|
||||
filesym = yasm_symrec_define_label(".file", NULL, NULL, 0, 0);
|
||||
yasm_symrec_set_of_data(filesym, &yasm_coff_LTX_objfmt, data);
|
||||
|
||||
entry = xmalloc(sizeof(coff_symtab_entry));
|
||||
entry = yasm_xmalloc(sizeof(coff_symtab_entry));
|
||||
entry->sym = filesym;
|
||||
entry->numaux = 1;
|
||||
entry->auxtype = COFF_SYMTAB_AUX_FILE;
|
||||
entry->aux[0].fname = xstrdup(in_filename);
|
||||
entry->aux[0].fname = yasm__xstrdup(in_filename);
|
||||
STAILQ_INSERT_TAIL(&coff_symtab, entry, link);
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
return 1;
|
||||
}
|
||||
|
||||
reloc = xmalloc(sizeof(coff_reloc));
|
||||
reloc = yasm_xmalloc(sizeof(coff_reloc));
|
||||
reloc->addr = bc->offset + offset;
|
||||
if (COFF_SET_VMA)
|
||||
reloc->addr += info->addr;
|
||||
|
|
@ -357,7 +357,7 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Don't bother doing anything else if size ended up being 0. */
|
||||
if (size == 0) {
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -384,7 +384,7 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
|
||||
/* If bigbuf was allocated, free it */
|
||||
if (bigbuf)
|
||||
xfree(bigbuf);
|
||||
yasm_xfree(bigbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -519,7 +519,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
coff_symtab_entry *entry;
|
||||
|
||||
info.f = f;
|
||||
info.buf = xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE);
|
||||
|
||||
/* Allocate space for headers by seeking forward */
|
||||
if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
|
||||
|
|
@ -686,7 +686,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
|
||||
yasm_sections_traverse(sections, &info, coff_objfmt_output_secthead);
|
||||
|
||||
xfree(info.buf);
|
||||
yasm_xfree(info.buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -699,8 +699,8 @@ coff_objfmt_cleanup(void)
|
|||
while (entry1 != NULL) {
|
||||
entry2 = STAILQ_NEXT(entry1, link);
|
||||
if (entry1->numaux == 1 && entry1->auxtype == COFF_SYMTAB_AUX_FILE)
|
||||
xfree(entry1->aux[0].fname);
|
||||
xfree(entry1);
|
||||
yasm_xfree(entry1->aux[0].fname);
|
||||
yasm_xfree(entry1);
|
||||
entry1 = entry2;
|
||||
}
|
||||
}
|
||||
|
|
@ -760,7 +760,7 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
coff_section_data *data;
|
||||
yasm_symrec *sym;
|
||||
|
||||
data = xmalloc(sizeof(coff_section_data));
|
||||
data = yasm_xmalloc(sizeof(coff_section_data));
|
||||
data->scnum = coff_objfmt_parse_scnum++;
|
||||
data->flags = flags;
|
||||
data->addr = 0;
|
||||
|
|
@ -790,10 +790,10 @@ coff_objfmt_section_data_delete(/*@only@*/ void *data)
|
|||
r1 = STAILQ_FIRST(&csd->relocs);
|
||||
while (r1 != NULL) {
|
||||
r2 = STAILQ_NEXT(r1, link);
|
||||
xfree(r1);
|
||||
yasm_xfree(r1);
|
||||
r1 = r2;
|
||||
}
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -868,7 +868,7 @@ coff_objfmt_symrec_data_delete(/*@only@*/ void *data)
|
|||
coff_symrec_data *csymd = (coff_symrec_data *)data;
|
||||
if (csymd->size)
|
||||
yasm_expr_delete(csymd->size);
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static void
|
|||
dbg_objfmt_section_data_delete(/*@only@*/ void *data)
|
||||
{
|
||||
fprintf(dbg_objfmt_file, "section_data_delete(%p)\n", data);
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -214,7 +214,7 @@ static void
|
|||
dbg_objfmt_bc_objfmt_data_delete(unsigned int type, /*@only@*/ void *data)
|
||||
{
|
||||
fprintf(dbg_objfmt_file, "symrec_data_delete(%u, %p)\n", type, data);
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ line: '\n' { $$ = (yasm_bytecode *)NULL; }
|
|||
yasm_intnum_get_uint($4));
|
||||
yasm_intnum_delete($2);
|
||||
yasm_intnum_delete($4);
|
||||
xfree($5);
|
||||
yasm_xfree($5);
|
||||
$$ = (yasm_bytecode *)NULL;
|
||||
}
|
||||
| '[' { nasm_parser_set_directive_state(); } directive ']' '\n' {
|
||||
|
|
@ -169,7 +169,7 @@ lineexp: exp
|
|||
| label TIMES expr exp { $$ = $4; yasm_bc_set_multiple($$, $3); }
|
||||
| label_id_equ EQU expr {
|
||||
yasm_symrec_define_equ($1, $3, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
$$ = (yasm_bytecode *)NULL;
|
||||
}
|
||||
;
|
||||
|
|
@ -236,22 +236,22 @@ dataval: dvexpr { $$ = yasm_dv_new_expr($1); }
|
|||
label: label_id {
|
||||
yasm_symrec_define_label($1, nasm_parser_cur_section,
|
||||
nasm_parser_prev_bc, 1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| label_id ':' {
|
||||
yasm_symrec_define_label($1, nasm_parser_cur_section,
|
||||
nasm_parser_prev_bc, 1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
;
|
||||
|
||||
label_id: ID {
|
||||
$$ = $1;
|
||||
if (nasm_parser_locallabel_base)
|
||||
xfree(nasm_parser_locallabel_base);
|
||||
yasm_xfree(nasm_parser_locallabel_base);
|
||||
nasm_parser_locallabel_base_len = strlen($1);
|
||||
nasm_parser_locallabel_base =
|
||||
xmalloc(nasm_parser_locallabel_base_len+1);
|
||||
yasm_xmalloc(nasm_parser_locallabel_base_len+1);
|
||||
strcpy(nasm_parser_locallabel_base, $1);
|
||||
}
|
||||
| SPECIAL_ID
|
||||
|
|
@ -265,11 +265,11 @@ label_id_equ: ID
|
|||
|
||||
/* directives */
|
||||
directive: DIRECTIVE_NAME directive_val {
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| DIRECTIVE_NAME error {
|
||||
yasm__error(cur_lindex, N_("invalid arguments to [%s]"), $1);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -304,7 +304,8 @@ directive_valparam: direxpr {
|
|||
*/
|
||||
const /*@null@*/ yasm_symrec *vp_symrec;
|
||||
if ((vp_symrec = yasm_expr_get_symrec(&$1, 0))) {
|
||||
yasm_vp_new($$, xstrdup(yasm_symrec_get_name(vp_symrec)), NULL);
|
||||
yasm_vp_new($$, yasm__xstrdup(yasm_symrec_get_name(vp_symrec)),
|
||||
NULL);
|
||||
yasm_expr_delete($1);
|
||||
} else {
|
||||
yasm_expr__traverse_leaves_in($1, NULL, fix_directive_symrec);
|
||||
|
|
@ -407,7 +408,7 @@ direxpr: INTNUM { $$ = p_expr_new_ident(yasm_expr_int($1)); }
|
|||
| ID {
|
||||
$$ = p_expr_new_ident(yasm_expr_sym(
|
||||
yasm_symrec_define_label($1, NULL, NULL, 0, cur_lindex)));
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| direxpr '|' direxpr { $$ = p_expr_new_tree($1, YASM_EXPR_OR, $3); }
|
||||
| direxpr '^' direxpr { $$ = p_expr_new_tree($1, YASM_EXPR_XOR, $3); }
|
||||
|
|
@ -468,7 +469,7 @@ expr: INTNUM { $$ = p_expr_new_ident(yasm_expr_int($1)); }
|
|||
| STRING {
|
||||
$$ = p_expr_new_ident(yasm_expr_int(
|
||||
yasm_intnum_new_charconst_nasm($1, cur_lindex)));
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| explabel { $$ = p_expr_new_ident(yasm_expr_sym($1)); }
|
||||
/*| expr '||' expr { $$ = p_expr_new_tree($1, YASM_EXPR_LOR, $3); }*/
|
||||
|
|
@ -503,15 +504,15 @@ expr: INTNUM { $$ = p_expr_new_ident(yasm_expr_int($1)); }
|
|||
|
||||
explabel: ID {
|
||||
$$ = yasm_symrec_use($1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| SPECIAL_ID {
|
||||
$$ = yasm_symrec_use($1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| LOCAL_ID {
|
||||
$$ = yasm_symrec_use($1, cur_lindex);
|
||||
xfree($1);
|
||||
yasm_xfree($1);
|
||||
}
|
||||
| '$' {
|
||||
/* "$" references the current assembly position */
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ nasm_parser_do_parse(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of,
|
|||
|
||||
/* Free locallabel base if necessary */
|
||||
if (nasm_parser_locallabel_base)
|
||||
xfree(nasm_parser_locallabel_base);
|
||||
yasm_xfree(nasm_parser_locallabel_base);
|
||||
|
||||
return &nasm_parser_sections;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ fill(YYCTYPE *cursor)
|
|||
if (!s.bot)
|
||||
first = 1;
|
||||
if((s.top - s.lim) < BSIZE){
|
||||
char *buf = xmalloc((s.lim - s.bot) + BSIZE);
|
||||
char *buf = yasm_xmalloc((s.lim - s.bot) + BSIZE);
|
||||
memcpy(buf, s.tok, s.lim - s.tok);
|
||||
s.tok = buf;
|
||||
s.ptr = &buf[s.ptr - s.bot];
|
||||
|
|
@ -101,7 +101,7 @@ fill(YYCTYPE *cursor)
|
|||
s.lim = &buf[s.lim - s.bot];
|
||||
s.top = &s.lim[BSIZE];
|
||||
if (s.bot)
|
||||
xfree(s.bot);
|
||||
yasm_xfree(s.bot);
|
||||
s.bot = buf;
|
||||
}
|
||||
if((cnt = nasm_parser_input(s.lim, BSIZE)) == 0){
|
||||
|
|
@ -122,7 +122,7 @@ fill(YYCTYPE *cursor)
|
|||
static void
|
||||
delete_line(/*@only@*/ void *data)
|
||||
{
|
||||
xfree(data);
|
||||
yasm_xfree(data);
|
||||
}
|
||||
|
||||
static YYCTYPE *
|
||||
|
|
@ -132,7 +132,7 @@ save_line(YYCTYPE *cursor)
|
|||
|
||||
/* save previous line using assoc_data */
|
||||
nasm_parser_linemgr->add_assoc_data(YASM_LINEMGR_STD_TYPE_SOURCE,
|
||||
xstrdup(cur_line), delete_line);
|
||||
yasm__xstrdup(cur_line), delete_line);
|
||||
/* save next line into cur_line */
|
||||
if ((YYLIMIT - YYCURSOR) < 80)
|
||||
YYFILL(80);
|
||||
|
|
@ -146,7 +146,7 @@ void
|
|||
nasm_parser_cleanup(void)
|
||||
{
|
||||
if (s.bot)
|
||||
xfree(s.bot);
|
||||
yasm_xfree(s.bot);
|
||||
}
|
||||
|
||||
/* starting size of string buffer */
|
||||
|
|
@ -355,7 +355,7 @@ scan:
|
|||
|
||||
/* special non-local ..@label and labels like ..start */
|
||||
".." [a-zA-Z0-9_$#@~.?]+ {
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(SPECIAL_ID);
|
||||
}
|
||||
|
||||
|
|
@ -363,15 +363,15 @@ scan:
|
|||
"." [a-zA-Z0-9_$#@~?][a-zA-Z0-9_$#@~.?]* {
|
||||
/* override local labels in directive state */
|
||||
if (state == DIRECTIVE2) {
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
} else if (!nasm_parser_locallabel_base) {
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("no non-local label before `%s'"), s.tok[0]);
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
} else {
|
||||
len = TOKLEN + nasm_parser_locallabel_base_len;
|
||||
yylval.str_val = xmalloc(len + 1);
|
||||
yylval.str_val = yasm_xmalloc(len + 1);
|
||||
strcpy(yylval.str_val, nasm_parser_locallabel_base);
|
||||
strncat(yylval.str_val, s.tok, TOKLEN);
|
||||
yylval.str_val[len] = '\0';
|
||||
|
|
@ -382,7 +382,7 @@ scan:
|
|||
|
||||
/* forced identifier */
|
||||
"$" [a-zA-Z_?][a-zA-Z0-9_$#@~.?]* {
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ scan:
|
|||
switch (check_id_ret) {
|
||||
case YASM_ARCH_CHECK_ID_NONE:
|
||||
/* Just an identifier, return as such. */
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
case YASM_ARCH_CHECK_ID_INSN:
|
||||
RETURN(INSN);
|
||||
|
|
@ -411,7 +411,7 @@ scan:
|
|||
default:
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("Arch feature not supported, treating as identifier"));
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
}
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ linechg2:
|
|||
|
||||
(any \ [\r\n])+ {
|
||||
state = LINECHG;
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(FILENAME);
|
||||
}
|
||||
*/
|
||||
|
|
@ -510,7 +510,7 @@ directive:
|
|||
|
||||
iletter+ {
|
||||
state = DIRECTIVE2;
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
yylval.str_val = yasm__xstrndup(s.tok, TOKLEN);
|
||||
RETURN(DIRECTIVE_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ directive:
|
|||
|
||||
/* string/character constant values */
|
||||
stringconst:
|
||||
strbuf = xmalloc(STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);
|
||||
strbuf_size = STRBUF_ALLOC_SIZE;
|
||||
count = 0;
|
||||
|
||||
|
|
@ -554,7 +554,7 @@ stringconst_scan:
|
|||
|
||||
strbuf[count++] = s.tok[0];
|
||||
if (count >= strbuf_size) {
|
||||
strbuf = xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf_size += STRBUF_ALLOC_SIZE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ nasm_preproc_input(char *buf, size_t max_size)
|
|||
tot += n;
|
||||
|
||||
if (n == lineleft) {
|
||||
xfree(line);
|
||||
yasm_xfree(line);
|
||||
line = NULL;
|
||||
} else {
|
||||
lineleft -= n;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
* passed a NULL pointer; nasm_free will do nothing if it is passed
|
||||
* a NULL pointer.
|
||||
*/
|
||||
#define nasm_malloc xmalloc
|
||||
#define nasm_realloc xrealloc
|
||||
#define nasm_free(p) if (p) xfree(p)
|
||||
#define nasm_strdup xstrdup
|
||||
#define nasm_strndup xstrndup
|
||||
#define nasm_malloc yasm_xmalloc
|
||||
#define nasm_realloc yasm_xrealloc
|
||||
#define nasm_free(p) yasm_xfree(p)
|
||||
#define nasm_strdup yasm__xstrdup
|
||||
#define nasm_strndup yasm__xstrndup
|
||||
#define nasm_stricmp yasm__strcasecmp
|
||||
#define nasm_strnicmp yasm__strncasecmp
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ replay_saved_tokens(char *ident,
|
|||
YAPP_Macro *
|
||||
yapp_macro_insert (char *name, int argc, int fillargs)
|
||||
{
|
||||
YAPP_Macro *ym = xmalloc(sizeof(YAPP_Macro));
|
||||
YAPP_Macro *ym = yasm_xmalloc(sizeof(YAPP_Macro));
|
||||
ym->type = YAPP_MACRO;
|
||||
ym->args = argc;
|
||||
ym->fillargs = fillargs;
|
||||
|
|
@ -147,7 +147,7 @@ yapp_define_insert (char *name, int argc, int fillargs)
|
|||
else if (argc >= 0)
|
||||
{
|
||||
/* insert placeholder for paramlisted defines */
|
||||
ym = xmalloc(sizeof(YAPP_Macro));
|
||||
ym = yasm_xmalloc(sizeof(YAPP_Macro));
|
||||
ym->type = YAPP_DEFINE;
|
||||
ym->args = argc;
|
||||
ym->fillargs = fillargs;
|
||||
|
|
@ -156,14 +156,14 @@ yapp_define_insert (char *name, int argc, int fillargs)
|
|||
}
|
||||
|
||||
/* now for the real one */
|
||||
ym = xmalloc(sizeof(YAPP_Macro));
|
||||
ym = yasm_xmalloc(sizeof(YAPP_Macro));
|
||||
ym->type = YAPP_DEFINE;
|
||||
ym->args = argc;
|
||||
ym->fillargs = fillargs;
|
||||
ym->expanding = 0;
|
||||
|
||||
if (argc>=0) {
|
||||
mungename = xmalloc(strlen(name)+8);
|
||||
mungename = yasm_xmalloc(strlen(name)+8);
|
||||
sprintf(mungename, "%s(%d)", name, argc);
|
||||
}
|
||||
|
||||
|
|
@ -188,10 +188,10 @@ yapp_macro_delete (YAPP_Macro *ym)
|
|||
{
|
||||
while (!SLIST_EMPTY(&ym->macro_head)) {
|
||||
source *s = SLIST_FIRST(&ym->macro_head);
|
||||
xfree(s);
|
||||
yasm_xfree(s);
|
||||
SLIST_REMOVE_HEAD(&ym->macro_head, next);
|
||||
}
|
||||
xfree(ym);
|
||||
yasm_xfree(ym);
|
||||
}
|
||||
|
||||
static YAPP_Macro *
|
||||
|
|
@ -240,14 +240,14 @@ yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
|||
{
|
||||
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
|
||||
yapp_preproc_linemgr = lm;
|
||||
yapp_preproc_current_file = xstrdup(in_filename);
|
||||
yapp_preproc_current_file = yasm__xstrdup(in_filename);
|
||||
yapp_preproc_line_number = 1;
|
||||
yapp_lex_initialize(f);
|
||||
SLIST_INIT(&output_head);
|
||||
SLIST_INIT(&source_head);
|
||||
SLIST_INIT(¯o_head);
|
||||
SLIST_INIT(¶m_head);
|
||||
out = xmalloc(sizeof(output));
|
||||
out = yasm_xmalloc(sizeof(output));
|
||||
out->out = current_output = YAPP_OUTPUT;
|
||||
SLIST_INSERT_HEAD(&output_head, out, next);
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ yapp_preproc_cleanup(void)
|
|||
static void
|
||||
push_if(int val)
|
||||
{
|
||||
out = xmalloc(sizeof(output));
|
||||
out = yasm_xmalloc(sizeof(output));
|
||||
out->out = current_output;
|
||||
SLIST_INSERT_HEAD(&output_head, out, next);
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ pop_if(void)
|
|||
out = SLIST_FIRST(&output_head);
|
||||
current_output = out->out;
|
||||
SLIST_REMOVE_HEAD(&output_head, next);
|
||||
xfree(out);
|
||||
yasm_xfree(out);
|
||||
if (current_output != YAPP_OUTPUT) set_inhibit();
|
||||
}
|
||||
|
||||
|
|
@ -373,49 +373,49 @@ append_token(int token, struct source_head *to_head, source **to_tail)
|
|||
if ((*to_tail) && (*to_tail)->token.type == LINE
|
||||
&& (token == '\n' || token == LINE))
|
||||
{
|
||||
xfree ((*to_tail)->token.str);
|
||||
(*to_tail)->token.str = xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
yasm_xfree ((*to_tail)->token.str);
|
||||
(*to_tail)->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
sprintf((*to_tail)->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file);
|
||||
}
|
||||
else {
|
||||
src = xmalloc(sizeof(source));
|
||||
src = yasm_xmalloc(sizeof(source));
|
||||
src->token.type = token;
|
||||
switch (token)
|
||||
{
|
||||
case INTNUM:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.int_str_val.str);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.int_str_val.str);
|
||||
src->token.val.int_val = yapp_preproc_lval.int_str_val.val;
|
||||
break;
|
||||
|
||||
case FLTNUM:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.double_str_val.str);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.double_str_val.str);
|
||||
src->token.val.double_val = yapp_preproc_lval.double_str_val.val;
|
||||
break;
|
||||
|
||||
case STRING:
|
||||
case WHITESPACE:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.str_val);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val);
|
||||
break;
|
||||
|
||||
case IDENT:
|
||||
src->token.str = xstrdup(yapp_preproc_lval.str_val);
|
||||
src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val);
|
||||
break;
|
||||
|
||||
case '+': case '-': case '*': case '/': case '%': case ',': case '\n':
|
||||
case '[': case ']': case '(': case ')':
|
||||
src->token.str = xmalloc(2);
|
||||
src->token.str = yasm_xmalloc(2);
|
||||
src->token.str[0] = (char)token;
|
||||
src->token.str[1] = '\0';
|
||||
break;
|
||||
|
||||
case LINE:
|
||||
/* TODO: consider removing any trailing newline or LINE tokens */
|
||||
src->token.str = xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
src->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file));
|
||||
sprintf(src->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file);
|
||||
break;
|
||||
|
||||
default:
|
||||
xfree(src);
|
||||
yasm_xfree(src);
|
||||
return;
|
||||
}
|
||||
append_processed_token(src, to_head, to_tail);
|
||||
|
|
@ -488,9 +488,9 @@ yapp_get_ident(const char *synlvl)
|
|||
void
|
||||
copy_token(YAPP_Token *tok, struct source_head *to_head, source **to_tail)
|
||||
{
|
||||
src = xmalloc(sizeof(source));
|
||||
src = yasm_xmalloc(sizeof(source));
|
||||
src->token.type = tok->type;
|
||||
src->token.str = xstrdup(tok->str);
|
||||
src->token.str = yasm__xstrdup(tok->str);
|
||||
|
||||
append_processed_token(src, to_head, to_tail);
|
||||
}
|
||||
|
|
@ -594,14 +594,14 @@ expand_macro(char *name,
|
|||
}
|
||||
|
||||
/* Now we have the argument count; let's see if it exists */
|
||||
mungename = xmalloc(strlen(name)+8);
|
||||
mungename = yasm_xmalloc(strlen(name)+8);
|
||||
sprintf(mungename, "%s(%d)", name, argc);
|
||||
ym = yapp_macro_get(mungename);
|
||||
if (!ym)
|
||||
{
|
||||
ydebug(("YAPP: -Didn't find macro %s\n", mungename));
|
||||
replay_saved_tokens(name, &replay_head, to_head, to_tail);
|
||||
xfree(mungename);
|
||||
yasm_xfree(mungename);
|
||||
return;
|
||||
}
|
||||
ydebug(("YAPP: +Found macro %s\n", mungename));
|
||||
|
|
@ -618,16 +618,16 @@ expand_macro(char *name,
|
|||
while (replay->token.type != '(') {
|
||||
ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str));
|
||||
SLIST_REMOVE_HEAD(&replay_head, next);
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
replay = SLIST_FIRST(&replay_head);
|
||||
}
|
||||
ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str));
|
||||
|
||||
/* free the open paren */
|
||||
SLIST_REMOVE_HEAD(&replay_head, next);
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
|
||||
param = SLIST_FIRST(&ym->param_head);
|
||||
|
||||
|
|
@ -651,14 +651,14 @@ expand_macro(char *name,
|
|||
|| replay->token.type == ')'))
|
||||
{
|
||||
int zero=0;
|
||||
struct source_head *argmacro = xmalloc(sizeof(struct source_head));
|
||||
struct source_head *argmacro = yasm_xmalloc(sizeof(struct source_head));
|
||||
memcpy(argmacro, &arg_head, sizeof(struct source_head));
|
||||
SLIST_INIT(&arg_head);
|
||||
arg_tail = SLIST_FIRST(&arg_head);
|
||||
|
||||
/* don't save the comma */
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
|
||||
HAMT_insert(param_table,
|
||||
param->token.str,
|
||||
|
|
@ -681,8 +681,8 @@ expand_macro(char *name,
|
|||
if (replay) SLIST_REMOVE_HEAD(&replay_head, next);
|
||||
}
|
||||
if (replay) {
|
||||
xfree(replay->token.str);
|
||||
xfree(replay);
|
||||
yasm_xfree(replay->token.str);
|
||||
yasm_xfree(replay);
|
||||
}
|
||||
else if (param) {
|
||||
yasm_internal_error(N_("Got to end of arglist before end of replay!"));
|
||||
|
|
@ -799,7 +799,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
ydebug(("YAPP: define: "));
|
||||
token = yapp_get_ident("define");
|
||||
ydebug((" \"%s\"\n", yapp_preproc_lval.str_val));
|
||||
s = xstrdup(yapp_preproc_lval.str_val);
|
||||
s = yasm__xstrdup(yapp_preproc_lval.str_val);
|
||||
|
||||
/* three cases: newline or stuff or left paren */
|
||||
token = yapp_preproc_lex();
|
||||
|
|
@ -936,8 +936,8 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
|
||||
saved_length -= strlen(src->token.str);
|
||||
SLIST_REMOVE_HEAD(&source_head, next);
|
||||
xfree(src->token.str);
|
||||
xfree(src);
|
||||
yasm_xfree(src->token.str);
|
||||
yasm_xfree(src);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@
|
|||
|
||||
#define yylval yapp_preproc_lval
|
||||
|
||||
#define malloc yasm_xmalloc
|
||||
#define realloc yasm_xrealloc
|
||||
|
||||
/* starting size of string buffer */
|
||||
#define STRBUF_ALLOC_SIZE 128
|
||||
|
||||
|
|
@ -124,7 +127,7 @@ DIR %[ \t]*
|
|||
int inch, count;
|
||||
char endch = yytext[0];
|
||||
|
||||
strbuf = xmalloc(STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);
|
||||
|
||||
strbuf_size = STRBUF_ALLOC_SIZE;
|
||||
inch = input();
|
||||
|
|
@ -132,7 +135,7 @@ DIR %[ \t]*
|
|||
while(inch != EOF && inch != endch && inch != '\n') {
|
||||
strbuf[count++] = inch;
|
||||
if(count >= strbuf_size) {
|
||||
strbuf = xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
|
||||
strbuf_size += STRBUF_ALLOC_SIZE;
|
||||
}
|
||||
inch = input();
|
||||
|
|
@ -153,7 +156,7 @@ DIR %[ \t]*
|
|||
\.\.[a-z0-9_$#@~.?]+ |
|
||||
\.[a-z0-9_$#@~?][a-z0-9_$#@~.?]* |
|
||||
[a-z_?][a-z0-9_$#@~.?]* {
|
||||
yylval.str_val = xstrdup(yytext);
|
||||
yylval.str_val = yasm__xstrdup(yytext);
|
||||
return IDENT;
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +169,7 @@ DIR %[ \t]*
|
|||
<incl>[^ \t\n"]* { /* have the filename */
|
||||
include *inc;
|
||||
FILE *incfile;
|
||||
inc = xmalloc(sizeof(include));
|
||||
inc = yasm_xmalloc(sizeof(include));
|
||||
inc->include_state = YY_CURRENT_BUFFER;
|
||||
|
||||
/* FIXME: handle includes that aren't relative */
|
||||
|
|
@ -174,7 +177,7 @@ DIR %[ \t]*
|
|||
if(!incfile) {
|
||||
yasm__error(cur_lindex, _("include file `%s': %s"),
|
||||
yytext, strerror(errno));
|
||||
xfree(inc);
|
||||
yasm_xfree(inc);
|
||||
}
|
||||
else {
|
||||
yyin = incfile;
|
||||
|
|
@ -183,7 +186,7 @@ DIR %[ \t]*
|
|||
SLIST_INSERT_HEAD(&includes_head, inc, next);
|
||||
|
||||
yapp_preproc_line_number = 1;
|
||||
yapp_preproc_current_file = xstrdup(yytext);
|
||||
yapp_preproc_current_file = yasm__xstrdup(yytext);
|
||||
BEGIN(INITIAL);
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
|
||||
}
|
||||
|
|
@ -200,11 +203,11 @@ DIR %[ \t]*
|
|||
inc = SLIST_FIRST(&includes_head);
|
||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer (inc->include_state);
|
||||
xfree(yapp_preproc_current_file);
|
||||
yasm_xfree(yapp_preproc_current_file);
|
||||
yapp_preproc_current_file = inc->filename;
|
||||
yapp_preproc_line_number = inc->line_number + 1;
|
||||
SLIST_REMOVE_HEAD(&includes_head, next);
|
||||
xfree(inc);
|
||||
yasm_xfree(inc);
|
||||
|
||||
BEGIN(incl);
|
||||
return INCLUDE;
|
||||
|
|
@ -228,8 +231,8 @@ DIR %[ \t]*
|
|||
}
|
||||
<line>{WS}+["] ; /* eat space before file */
|
||||
<line>[^ \t\n"]* { /* have the filename */
|
||||
xfree(yapp_preproc_current_file);
|
||||
yapp_preproc_current_file = xstrdup(yytext);
|
||||
yasm_xfree(yapp_preproc_current_file);
|
||||
yapp_preproc_current_file = yasm__xstrdup(yytext);
|
||||
}
|
||||
<line>["]{WS}*\n {
|
||||
BEGIN(INITIAL);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ yasm_sections_initialize(yasm_sectionhead *headp, yasm_objfmt *of)
|
|||
STAILQ_INIT(headp);
|
||||
|
||||
/* Add an initial "default" section */
|
||||
yasm_vp_new(vp, xstrdup(of->default_section_name), NULL);
|
||||
yasm_vp_new(vp, yasm__xstrdup(of->default_section_name), NULL);
|
||||
yasm_vps_initialize(&vps);
|
||||
yasm_vps_append(&vps, vp);
|
||||
s = of->sections_switch(headp, &vps, NULL, 0);
|
||||
|
|
@ -105,11 +105,11 @@ yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
|||
/* No: we have to allocate and create a new one. */
|
||||
|
||||
/* Okay, the name is valid; now allocate and initialize */
|
||||
s = xcalloc(1, sizeof(yasm_section));
|
||||
s = yasm_xcalloc(1, sizeof(yasm_section));
|
||||
STAILQ_INSERT_TAIL(headp, s, link);
|
||||
|
||||
s->type = SECTION_GENERAL;
|
||||
s->data.general.name = xstrdup(name);
|
||||
s->data.general.name = yasm__xstrdup(name);
|
||||
s->data.general.of = NULL;
|
||||
s->data.general.of_data = NULL;
|
||||
s->start = yasm_expr_new_ident(yasm_expr_int(yasm_intnum_new_uint(start)),
|
||||
|
|
@ -130,7 +130,7 @@ yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start)
|
|||
{
|
||||
yasm_section *s;
|
||||
|
||||
s = xcalloc(1, sizeof(yasm_section));
|
||||
s = yasm_xcalloc(1, sizeof(yasm_section));
|
||||
STAILQ_INSERT_TAIL(headp, s, link);
|
||||
|
||||
s->type = SECTION_ABSOLUTE;
|
||||
|
|
@ -290,7 +290,7 @@ yasm_section_delete(yasm_section *sect)
|
|||
return;
|
||||
|
||||
if (sect->type == SECTION_GENERAL) {
|
||||
xfree(sect->data.general.name);
|
||||
yasm_xfree(sect->data.general.name);
|
||||
if (sect->data.general.of_data && sect->data.general.of) {
|
||||
yasm_objfmt *of = sect->data.general.of;
|
||||
if (of->section_data_delete)
|
||||
|
|
@ -302,7 +302,7 @@ yasm_section_delete(yasm_section *sect)
|
|||
}
|
||||
yasm_expr_delete(sect->start);
|
||||
yasm_bcs_delete(§->bc);
|
||||
xfree(sect);
|
||||
yasm_xfree(sect);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
16
src/symrec.c
16
src/symrec.c
|
|
@ -97,7 +97,7 @@ void
|
|||
yasm_symrec_initialize(void)
|
||||
{
|
||||
sym_table = HAMT_new(yasm_internal_error_);
|
||||
non_table_syms = xmalloc(sizeof(nontablesymhead));
|
||||
non_table_syms = yasm_xmalloc(sizeof(nontablesymhead));
|
||||
SLIST_INIT(non_table_syms);
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ static void
|
|||
symrec_delete_one(/*@only@*/ void *d)
|
||||
{
|
||||
yasm_symrec *sym = d;
|
||||
xfree(sym->name);
|
||||
yasm_xfree(sym->name);
|
||||
if (sym->type == SYM_EQU)
|
||||
yasm_expr_delete(sym->value.expn);
|
||||
if (sym->of_data && sym->of) {
|
||||
|
|
@ -115,13 +115,13 @@ symrec_delete_one(/*@only@*/ void *d)
|
|||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific data"));
|
||||
}
|
||||
xfree(sym);
|
||||
yasm_xfree(sym);
|
||||
}
|
||||
|
||||
static /*@partial@*/ yasm_symrec *
|
||||
symrec_new_common(/*@keep@*/ char *name)
|
||||
{
|
||||
yasm_symrec *rec = xmalloc(sizeof(yasm_symrec));
|
||||
yasm_symrec *rec = yasm_xmalloc(sizeof(yasm_symrec));
|
||||
rec->name = name;
|
||||
rec->type = SYM_UNKNOWN;
|
||||
rec->line = 0;
|
||||
|
|
@ -146,7 +146,7 @@ symrec_get_or_new_in_table(/*@only@*/ char *name)
|
|||
static /*@partial@*/ /*@dependent@*/ yasm_symrec *
|
||||
symrec_get_or_new_not_in_table(/*@only@*/ char *name)
|
||||
{
|
||||
non_table_symrec *sym = xmalloc(sizeof(non_table_symrec));
|
||||
non_table_symrec *sym = yasm_xmalloc(sizeof(non_table_symrec));
|
||||
sym->rec = symrec_new_common(name);
|
||||
|
||||
sym->rec->status = SYM_NOTINTABLE;
|
||||
|
|
@ -161,7 +161,7 @@ symrec_get_or_new_not_in_table(/*@only@*/ char *name)
|
|||
static /*@partial@*/ /*@dependent@*/ yasm_symrec *
|
||||
symrec_get_or_new(const char *name, int in_table)
|
||||
{
|
||||
char *symname = xstrdup(name);
|
||||
char *symname = yasm__xstrdup(name);
|
||||
|
||||
if (in_table)
|
||||
return symrec_get_or_new_in_table(symname);
|
||||
|
|
@ -360,9 +360,9 @@ yasm_symrec_cleanup(void)
|
|||
non_table_symrec *sym = SLIST_FIRST(non_table_syms);
|
||||
SLIST_REMOVE_HEAD(non_table_syms, link);
|
||||
symrec_delete_one(sym->rec);
|
||||
xfree(sym);
|
||||
yasm_xfree(sym);
|
||||
}
|
||||
xfree(non_table_syms);
|
||||
yasm_xfree(non_table_syms);
|
||||
}
|
||||
|
||||
typedef struct symrec_print_data {
|
||||
|
|
|
|||
34
src/util.h
34
src/util.h
|
|
@ -126,21 +126,33 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* strdup() implementation with error checking (using xmalloc). */
|
||||
/*@only@*/ char *xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines in xmalloc.c. */
|
||||
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
|
||||
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
|
||||
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
|
||||
void *oldmem, size_t size) /*@modifies oldmem@*/;
|
||||
void xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p) /*@modifies p@*/;
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
# include <dmalloc.h>
|
||||
|
||||
#define yasm__xstrdup(str) xstrdup(str)
|
||||
#define yasm_xmalloc(size) xmalloc(size)
|
||||
#define yasm_xcalloc(count, size) xcalloc(count, size)
|
||||
#define yasm_xrealloc(ptr, size) xrealloc(ptr, size)
|
||||
#define yasm_xfree(ptr) xfree(ptr)
|
||||
|
||||
#else
|
||||
/* strdup() implementation with error checking (using xmalloc). */
|
||||
/*@only@*/ char *yasm__xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines. Default implementations in
|
||||
* xmalloc.c.
|
||||
*/
|
||||
extern /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size);
|
||||
extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize);
|
||||
extern /*@only@*/ void * (*yasm_xrealloc)
|
||||
(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size)
|
||||
/*@modifies oldmem@*/;
|
||||
extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
|
||||
/*@modifies p@*/;
|
||||
|
||||
#endif
|
||||
|
||||
/*@only@*/ char *xstrndup(const char *str, size_t len);
|
||||
/*@only@*/ char *yasm__xstrndup(const char *str, size_t len);
|
||||
|
||||
/* Bit-counting: used primarily by HAMT but also in a few other places. */
|
||||
#define SK5 0x55555555
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ yasm_vps_delete(yasm_valparamhead *headp)
|
|||
while (cur) {
|
||||
next = STAILQ_NEXT(cur, link);
|
||||
if (cur->val)
|
||||
xfree(cur->val);
|
||||
yasm_xfree(cur->val);
|
||||
if (cur->param)
|
||||
yasm_expr_delete(cur->param);
|
||||
xfree(cur);
|
||||
yasm_xfree(cur);
|
||||
cur = next;
|
||||
}
|
||||
STAILQ_INIT(headp);
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ typedef /*@reldef@*/ STAILQ_HEAD(yasm_valparamhead, yasm_valparam)
|
|||
|
||||
void yasm_vp_new(/*@out@*/ yasm_valparam *r, /*@keep@*/ const char *v,
|
||||
/*@keep@*/ yasm_expr *p);
|
||||
#define yasm_vp_new(r, v, p) do { \
|
||||
r = xmalloc(sizeof(yasm_valparam)); \
|
||||
r->val = v; \
|
||||
r->param = p; \
|
||||
#define yasm_vp_new(r, v, p) do { \
|
||||
r = yasm_xmalloc(sizeof(yasm_valparam)); \
|
||||
r->val = v; \
|
||||
r->param = p; \
|
||||
} while(0)
|
||||
|
||||
/* void yasm_vps_initialize(//@out@// yasm_valparamhead *headp); */
|
||||
|
|
|
|||
|
|
@ -32,8 +32,26 @@ RCSID("$IdPath$");
|
|||
|
||||
#ifndef WITH_DMALLOC
|
||||
|
||||
void *
|
||||
xmalloc(size_t size)
|
||||
static /*@only@*/ /*@out@*/ void *def_xmalloc(size_t size);
|
||||
static /*@only@*/ void *def_xcalloc(size_t nelem, size_t elsize);
|
||||
static /*@only@*/ void *def_xrealloc
|
||||
(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size)
|
||||
/*@modifies oldmem@*/;
|
||||
static void def_xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p)
|
||||
/*@modifies p@*/;
|
||||
|
||||
/* storage for global function pointers */
|
||||
/*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size) = def_xmalloc;
|
||||
/*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize) = def_xcalloc;
|
||||
/*@only@*/ void * (*yasm_xrealloc)
|
||||
(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size)
|
||||
/*@modifies oldmem@*/ = def_xrealloc;
|
||||
void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
|
||||
/*@modifies p@*/ = def_xfree;
|
||||
|
||||
|
||||
static void *
|
||||
def_xmalloc(size_t size)
|
||||
{
|
||||
void *newmem;
|
||||
|
||||
|
|
@ -46,8 +64,8 @@ xmalloc(size_t size)
|
|||
return newmem;
|
||||
}
|
||||
|
||||
void *
|
||||
xcalloc(size_t nelem, size_t elsize)
|
||||
static void *
|
||||
def_xcalloc(size_t nelem, size_t elsize)
|
||||
{
|
||||
void *newmem;
|
||||
|
||||
|
|
@ -61,8 +79,8 @@ xcalloc(size_t nelem, size_t elsize)
|
|||
return newmem;
|
||||
}
|
||||
|
||||
void *
|
||||
xrealloc(void *oldmem, size_t size)
|
||||
static void *
|
||||
def_xrealloc(void *oldmem, size_t size)
|
||||
{
|
||||
void *newmem;
|
||||
|
||||
|
|
@ -78,8 +96,8 @@ xrealloc(void *oldmem, size_t size)
|
|||
return newmem;
|
||||
}
|
||||
|
||||
void
|
||||
xfree(void *p)
|
||||
static void
|
||||
def_xfree(void *p)
|
||||
{
|
||||
if (!p)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -50,24 +50,24 @@ void memcpy(void *, const void *, size_t);
|
|||
#ifndef WITH_DMALLOC
|
||||
|
||||
char *
|
||||
xstrdup(const char *str)
|
||||
yasm__xstrdup(const char *str)
|
||||
{
|
||||
size_t len;
|
||||
char *copy;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
copy = xmalloc(len);
|
||||
copy = yasm_xmalloc(len);
|
||||
memcpy(copy, str, len);
|
||||
return (copy);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
xstrndup(const char *str, size_t len)
|
||||
yasm__xstrndup(const char *str, size_t len)
|
||||
{
|
||||
char *copy;
|
||||
|
||||
copy = xmalloc(len+1);
|
||||
copy = yasm_xmalloc(len+1);
|
||||
memcpy(copy, str, len);
|
||||
copy[len] = '\0';
|
||||
return (copy);
|
||||
|
|
|
|||
34
util.h
34
util.h
|
|
@ -126,21 +126,33 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* strdup() implementation with error checking (using xmalloc). */
|
||||
/*@only@*/ char *xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines in xmalloc.c. */
|
||||
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
|
||||
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
|
||||
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
|
||||
void *oldmem, size_t size) /*@modifies oldmem@*/;
|
||||
void xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p) /*@modifies p@*/;
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
# include <dmalloc.h>
|
||||
|
||||
#define yasm__xstrdup(str) xstrdup(str)
|
||||
#define yasm_xmalloc(size) xmalloc(size)
|
||||
#define yasm_xcalloc(count, size) xcalloc(count, size)
|
||||
#define yasm_xrealloc(ptr, size) xrealloc(ptr, size)
|
||||
#define yasm_xfree(ptr) xfree(ptr)
|
||||
|
||||
#else
|
||||
/* strdup() implementation with error checking (using xmalloc). */
|
||||
/*@only@*/ char *yasm__xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines. Default implementations in
|
||||
* xmalloc.c.
|
||||
*/
|
||||
extern /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size);
|
||||
extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize);
|
||||
extern /*@only@*/ void * (*yasm_xrealloc)
|
||||
(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size)
|
||||
/*@modifies oldmem@*/;
|
||||
extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p)
|
||||
/*@modifies p@*/;
|
||||
|
||||
#endif
|
||||
|
||||
/*@only@*/ char *xstrndup(const char *str, size_t len);
|
||||
/*@only@*/ char *yasm__xstrndup(const char *str, size_t len);
|
||||
|
||||
/* Bit-counting: used primarily by HAMT but also in a few other places. */
|
||||
#define SK5 0x55555555
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue