[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] pickles: pcap: fix PCAP_Packet body
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH] pickles: pcap: fix PCAP_Packet body |
Date: |
Sat, 7 Jan 2023 07:55:57 +0100 |
2022-01-07 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* pickles/pcap.pk (PCAP_Packet): Declare body as a byte array.
---
Hi Jose.
The old code was wrong (my mistake), I suggest to use array syntax, despite
the fact it'll slow down everything.
I feels more idiomatic than `byte[0]'-technique.
IMHO Poke is about describing (and poking!) data and should remain as
declarative as possible.
Maybe we can make PVM faster by somehow annotating big data fields.
Like `lazy byte[len] data;` or ...
WDYT?
Regards,
Mohammad-Reza
ChangeLog | 4 ++++
pickles/pcap.pk | 13 +------------
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f9a5f58a..33cc53cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-01-07 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * pickles/pcap.pk (PCAP_Packet): Declare body as a byte array.
+
2022-12-22 Darshit Shah <darnir@gnu.org>
* doc/poke.texi: Simplify Hyperlink setup by calling `make install`
diff --git a/pickles/pcap.pk b/pickles/pcap.pk
index 45b8cd22..f911f8e4 100644
--- a/pickles/pcap.pk
+++ b/pickles/pcap.pk
@@ -66,18 +66,7 @@ type PCAP_Packet =
struct
{
PCAP_PacketHeader header;
-
- var body_offset = OFFSET;
- var body_length = header.incl_len;
-
- byte[0] @ body_offset + body_length; /* End-of-packet marker */
-
- method get_body_offset = offset<uint32,B>: { return body_offset; }
- method get_body_length = offset<uint32,B>: { return body_length; }
- method get_body = byte[]:
- {
- return byte[body_length] @ body_offset;
- }
+ byte[header.incl_len] body;
};
type PCAP =
--
2.39.0
- [PATCH] pickles: pcap: fix PCAP_Packet body,
Mohammad-Reza Nabipoor <=