Files
unixprog2024-hw3/vector.c
2025-04-12 08:26:23 +08:00

28 lines
575 B
C

#include "vector.h"
#include <stdlib.h>
struct bps_node *bps = NULL;
int bps_len = 0, bps_cnt = 0, bps_max = 0;
const struct bps_node *find(uint64_t addr)
{
for (int i = 0; i < bps_len; i++)
if (bps[i].addr && bps[i].addr == addr)
return &bps[i];
return NULL;
}
int bps_push(uint64_t addr, uint8_t data)
{
if (bps_max == 0)
bps = malloc((bps_max = 1) * sizeof(struct bps_node));
if (bps_len + 1 >= bps_max)
bps = realloc(bps, (bps_max <<= 1) * sizeof(struct bps_node));
bps[bps_len].addr = addr;
bps[bps_len].data = data;
bps_cnt++;
return bps_len++;
}