Add basic packet buffer definition

This commit is contained in:
Piper Pentagram 2025-05-13 13:18:22 -07:00
parent 0baae86beb
commit fb762b2aef
3 changed files with 25 additions and 2 deletions

11
include/packet_buffer.h Normal file
View file

@ -0,0 +1,11 @@
#pragma once
#include <stddef.h>
#define PACKET_BUFFER_SIZE 512
struct PacketBuffer {
char buf[PACKET_BUFFER_SIZE];
size_t pos;
};
struct PacketBuffer *new_packet_buffer();

View file

@ -1,8 +1,11 @@
#include "pupdns.h" #include <stdio.h>
#include "packet_buffer.h"
int main() int main()
{ {
printf("Hello, world!\n"); struct PacketBuffer *buf = new_packet_buffer();
printf("size: %ld\n", sizeof(buf->buf));
return 0; return 0;
} }

9
src/packet_buffer.c Normal file
View file

@ -0,0 +1,9 @@
#include "packet_buffer.h"
#include <stdlib.h>
struct PacketBuffer *new_packet_buffer()
{
struct PacketBuffer *buf;
buf = malloc(sizeof(struct PacketBuffer));
return buf;
}