/*************************************************************//** Prints the contents of a memory buffer in hex and ascii. */ UNIV_INTERN void ut_print_buf( /*=========*/ FILE* file, /*!< in: file where to print */ const void* buf, /*!< in: memory buffer */ ulint len) /*!< in: length of the buffer */ { const byte* data; ulint i; UNIV_MEM_ASSERT_RW(buf, len); fprintf(file, " len %lu; hex ", len); for (data = (const byte*)buf, i = 0; i < len; i++) { fprintf(file, "%02lx", (ulong)*data++); } fputs("; asc ", file); data = (const byte*)buf; for (i = 0; i < len; i++) { int c = (int) *data++; putc(isprint(c) ? c : ' ', file); } putc(';', file); }
/**********************************************************//** Validates the consistency of a tuple which must be complete, i.e, all fields must have been set. @return TRUE if ok */ UNIV_INTERN ibool dtuple_validate( /*============*/ const dtuple_t* tuple) /*!< in: tuple */ { const dfield_t* field; ulint n_fields; ulint len; ulint i; ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N); n_fields = dtuple_get_n_fields(tuple); /* We dereference all the data of each field to test for memory traps */ for (i = 0; i < n_fields; i++) { field = dtuple_get_nth_field(tuple, i); len = dfield_get_len(field); if (!dfield_is_null(field)) { const byte* data = dfield_get_data(field); #ifndef UNIV_DEBUG_VALGRIND ulint j; for (j = 0; j < len; j++) { data_dummy += *data; /* fool the compiler not to optimize out this code */ data++; } #endif /* !UNIV_DEBUG_VALGRIND */ UNIV_MEM_ASSERT_RW(data, len); } } ut_a(dtuple_check_typed(tuple)); return(TRUE); }