variable target ui flush & message bitcount function
[vg.git] / vg_msg.h
index 5ae56c4d708de6d6fe7921d6a9d0bb849ffde2fb..b5fb4a482bf991ef4624b65ab93b89be33da51a6 100644 (file)
--- a/vg_msg.h
+++ b/vg_msg.h
@@ -262,10 +262,15 @@ static u32 vg_msg_cmd_bytecount( u8 code ){
    return vg_msg_cmd_array_count( code ) * vg_msg_cmd_type_size( code );
 }
 
+static u8 vg_msg_count_bits( u32 count ){
+   assert( (count <= 16) && count );
+   return ((count-1)<<2);
+}
+
 /* write a sized type */
 static void vg_msg_wkvnum( vg_msg *msg, const char *key,
                            u8 type, u8 count, void *data ){
-   u8 code = type | ((count-1)<<2);
+   u8 code = type | vg_msg_count_bits(count);
 
    vg_msg_wbuf( msg, &code, 1 );
    vg_msg_wstr( msg, key );