fix issue with the question to byte

This commit is contained in:
Mylloon 2023-06-05 21:23:53 +02:00
parent b16cf6df7c
commit 1e1ee73fbc
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 7 additions and 4 deletions

View file

@ -3,7 +3,7 @@ open Utils
let header_to_bytes header = let header_to_bytes header =
new_buffer new_buffer
header (2 * get_obj_size header)
[ header.id [ header.id
; header.flags ; header.flags
; header.num_questions ; header.num_questions
@ -14,7 +14,9 @@ let header_to_bytes header =
;; ;;
let question_to_bytes question = let question_to_bytes question =
let buffer = new_buffer question [ question.type_; question.class_ ] in let buffer =
new_buffer (2 * (get_obj_size question - 1)) [ question.type_; question.class_ ]
in
Bytes.cat buffer question.name Bytes.cat buffer question.name
;; ;;

View file

@ -11,8 +11,9 @@ let get_bytecode data =
String.concat "" result String.concat "" result
;; ;;
let new_buffer obj list = let get_obj_size obj = Obj.size (Obj.repr obj)
let size = 2 * Obj.size (Obj.repr obj) in
let new_buffer size list =
let buffer = Bytes.create size in let buffer = Bytes.create size in
let verification = let verification =
List.fold_left List.fold_left