Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
- `README`: Mention PowerTools for libpcap-devel
- `RefCountString`: Use anonymous array for `data`
  • Loading branch information
jelu committed Aug 16, 2023
1 parent 740a99e commit 75283cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -48,7 +48,7 @@ To install the dependencies under Debian/Ubuntu:
apt-get install -y zlib1g-dev libmaxminddb-dev
```

To install the dependencies under CentOS (with EPEL enabled):
To install the dependencies under CentOS (with EPEL/PowerTools enabled):
```
yum install -y zlib-devel libmaxminddb-devel
```
Expand Down
6 changes: 2 additions & 4 deletions src/refcountstring.h
Expand Up @@ -33,7 +33,7 @@
struct RefCountString {
// data
int count;
char data[sizeof(int)]; // this is a dummy, actual array will be larger
char data[];

// implementation
void inc_refcount()
Expand All @@ -50,9 +50,7 @@ struct RefCountString {

static RefCountString* allocate(int data_length)
{
std::size_t size = sizeof(RefCountString) - sizeof(char[sizeof(int)]) + data_length * sizeof(char);

void* chunk = std::calloc(1, size);
void* chunk = std::calloc(1, sizeof(RefCountString) + data_length);
if (!chunk)
throw std::bad_alloc();

Expand Down

0 comments on commit 75283cc

Please sign in to comment.