core/x86/instr.c
/* Frees all dynamically allocated storage that was allocated by instr,
 * except for allocated raw bits.
 * Also zeroes out instr's fields, except for raw bit fields and next and prev
 * fields, whether instr is ok to mangle, and instr's x86 mode.
 * Use this routine when you want to decode more information into the
 * same instr_t structure.
 * This instr must have been initialized before!
 */
Frees all dynamically allocated storage that was allocated by instr,
except for allocated raw bits.
Also zeroes out instr's fields, except for raw bit fields and next and prev
fields, whether instr is ok to mangle, and instr's x86 mode.
Use this routine when you want to decode more information into the
same instr_t structure.
This instr must have been initialized before!
Frees all dynamically allocated storage that was allocated by instr except for allocated raw bits . Also zeroes out instr ' s fields except for raw bit fields and next and prev fields whether instr is ok to mangle and instr ' s x86 mode . Use this routine when you want to decode more information into the same instr_t structure . This instr must have been initialized before!
void 
instr_reuse(dcontext_t *dcontext, instr_t *instr)
{
    byte *bits = NULL;
    uint len = 0;
    bool alloc = false;
    bool mangle = instr_ok_to_mangle(instr);
#ifdef X64
    bool x86_mode = instr_get_x86_mode(instr);
    uint rip_rel_pos = instr_rip_rel_valid(instr) ? instr->rip_rel_pos : 0;
#endif
    instr_t *next = instr->next;
    instr_t *prev = instr->prev;
    if (instr_raw_bits_valid(instr)) {
        if (instr_has_allocated_bits(instr)) {
            instr->flags &= ~INSTR_RAW_BITS_ALLOCATED;
            alloc = true;
        }
        bits = instr->bytes;
        len = instr->length;
    }
    instr_free(dcontext, instr);
    instr_init(dcontext, instr);
    instr->next = next;
    instr->prev = prev;
    if (bits != NULL) {
        instr->bytes = bits;
        instr->length = len;
        instr->flags |= INSTR_RAW_BITS_VALID;
        if (alloc)
            instr->flags |= INSTR_RAW_BITS_ALLOCATED;
    }
#ifdef X64
    instr_set_x86_mode(instr, x86_mode);
    if (rip_rel_pos > 0)
        instr_set_rip_rel_pos(instr, rip_rel_pos);
#endif
    if (!mangle)
        instr->flags |= INSTR_DO_NOT_MANGLE;
}
void instr_reuse ( dcontext_t * dcontext , instr_t * instr ) { byte * bits = NULL ; uint len = 0 ; bool alloc = false ; bool mangle = instr_ok_to_mangle ( instr ) ; #ifdef X64 bool x86_mode = instr_get_x86_mode ( instr ) ; uint rip_rel_pos = instr_rip_rel_valid ( instr ) ? instr -> rip_rel_pos : 0 ; #endif instr_t * next = instr -> next ; instr_t * prev = instr -> prev ; if ( instr_raw_bits_valid ( instr ) ) { if ( instr_has_allocated_bits ( instr ) ) { instr -> flags &= ~ INSTR_RAW_BITS_ALLOCATED ; alloc = true ; } bits = instr -> bytes ; len = instr -> length ; } instr_free ( dcontext , instr ) ; instr_init ( dcontext , instr ) ; instr -> next = next ; instr -> prev = prev ; if ( bits != NULL ) { instr -> bytes = bits ; instr -> length = len ; instr -> flags |= INSTR_RAW_BITS_VALID ; if ( alloc ) instr -> flags |= INSTR_RAW_BITS_ALLOCATED ; } #ifdef X64 instr_set_x86_mode ( instr , x86_mode ) ; if ( rip_rel_pos > 0 ) instr_set_rip_rel_pos ( instr , rip_rel_pos ) ; #endif if ( ! mangle ) instr -> flags |= INSTR_DO_NOT_MANGLE ; }
Frees all dynamically allocated storage that was allocated by instr,
 except for allocated raw bits.
Frees all dynamically allocated storage that was allocated by instr except for allocated raw bits .
/* pretend has no allocated bits to prevent freeing of them */ /* now re-add them */ /* assume that the bits are now valid and the operands are not
         * (operand and eflags flags are already unset from init)
         */ /* preserve across the up-decode */