subsys/debug/gdb_server.c
/*
 * Compress memory pointed to by buffer into its ascii hex value, the
 * character '*' and the number of times it is reapeated, placing result in
 * the same buffer. Return a pointer to the last char put in buf (null).
 */
Compress memory pointed to by buffer into its ascii hex value, the
character '*' and the number of times it is reapeated, placing result in
the same buffer. Return a pointer to the last char put in buf (null).
Compress memory pointed to by buffer into its ascii hex value the character ' * ' and the number of times it is reapeated placing result in the same buffer . Return a pointer to the last char put in buf ( null ) .
static unsigned char *compress(unsigned char *buf)
{
	unsigned char *read_ptr = buf;
	unsigned char *write_ptr = buf;
	unsigned char ch;
	size_t count = strlen((char *)buf);
	int max_repeat = 126 - 29;
	size_t ix;
	for (ix = 0; ix < count; ix++) {
		int num = 0;
		int jx;
		ch = *read_ptr++;
		*write_ptr++ = ch;
		for (jx = 1; ((jx + ix) < count) && (jx < max_repeat); jx++) {
			if (read_ptr[jx - 1] == ch) {
				num++;
			} else {
				break;
			}
		}
		if (num >= 3) {
			while (!is_size_encoder(num)) {
				num--;
			}
			*write_ptr++ = '*';
			*write_ptr++ = (unsigned char)(num + 29);
			read_ptr += num;
			ix += num;
		}
	}
	*write_ptr = 0;
	return write_ptr;
}
static unsigned char * compress ( unsigned char * buf ) { unsigned char * read_ptr = buf ; unsigned char * write_ptr = buf ; unsigned char ch ; size_t count = strlen ( ( char * ) buf ) ; int max_repeat = 126 - 29 ; size_t ix ; for ( ix = 0 ; ix < count ; ix ++ ) { int num = 0 ; int jx ; ch = * read_ptr ++ ; * write_ptr ++ = ch ; for ( jx = 1 ; ( ( jx + ix ) < count ) && ( jx < max_repeat ) ; jx ++ ) { if ( read_ptr [ jx - 1 ] == ch ) { num ++ ; } else { break ; } } if ( num >= 3 ) { while ( ! is_size_encoder ( num ) ) { num -- ; } * write_ptr ++ = ' ' ; * write_ptr ++ = ( unsigned char ) ( num + 29 ) ; read_ptr += num ; ix += num ; } } * write_ptr = 0 ; return write_ptr ; }
Compress memory pointed to by buffer into its ascii hex value, the
 character '*' and the number of times it is reapeated, placing result in
 the same buffer.
Compress memory pointed to by buffer into its ascii hex value the character ' * ' and the number of times it is reapeated placing result in the same buffer .
/*
			 * Skip characters that cannot be used as size
			 * encoders.
			 */