Skip to content

Commit

Permalink
Cleanup nfprofile and fix issue #398
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed May 19, 2023
1 parent 69e4d98 commit f2ddf67
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 46 deletions.
8 changes: 8 additions & 0 deletions src/inline/nffile_inline.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ static inline size_t CheckBufferSpace(nffile_t *nffile, size_t required);

static inline void AppendToBuffer(nffile_t *nffile, void *record, size_t required);

static inline void ClearMasterRecord(master_record_t *record);

static inline void ExpandRecord_v3(recordHeaderV3_t *v3Record, master_record_t *output_record);

#ifdef NEED_PACKRECORD
Expand Down Expand Up @@ -66,6 +68,12 @@ static inline size_t CheckBufferSpace(nffile_t *nffile, size_t required) {

} // End of CheckBufferSpace

static inline void ClearMasterRecord(master_record_t *record) {
if (record->inPayload) free(record->inPayload);
if (record->outPayload) free(record->outPayload);
memset((void *)record, 0, sizeof(master_record_t));
} // End of ClearMasterRecord

static inline void ExpandRecord_v3(recordHeaderV3_t *v3Record, master_record_t *output_record) {
elementHeader_t *elementHeader;
uint32_t size = sizeof(recordHeaderV3_t);
Expand Down
7 changes: 5 additions & 2 deletions src/lib/nffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@
static const char *nf_creator[MAX_CREATOR] = {"unknown", "nfcapd", "nfpcapd", "sfcapd", "nfdump", "nfanon", "nfprofile", "geolookup", "ft2nfdump"};

/* function prototypes */
static HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS);

static int LZO_initialize(void);

static int LZ4_initialize(void);
Expand Down Expand Up @@ -188,6 +186,8 @@ static int Compress_Block_LZO(dataBlock_t *in_block, dataBlock_t *out_block, siz
out = (unsigned char __LZO_MMODEL *)((void *)out_block + sizeof(dataBlock_t));
lzo_uint in_len = in_block->size;
lzo_uint out_len = 0;

static HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS);
r = lzo1x_1_compress(in, in_len, out, &out_len, wrkmem);

if (r != LZO_E_OK) {
Expand Down Expand Up @@ -966,6 +966,7 @@ void DisposeFile(nffile_t *nffile) {
FreeDataBlock(p);
}

queue_free(nffile->processQueue);
free(nffile);

} // End of DisposeFile
Expand Down Expand Up @@ -1707,6 +1708,8 @@ int QueryFile(char *filename, int verbose) {
}
}

FreeDataBlock(buff);

off_t fsize = lseek(fd, 0, SEEK_CUR);
if (fsize < stat_buf.st_size) {
LogError("Extra data detected after regular blocks: %i bytes", stat_buf.st_size - fsize);
Expand Down
8 changes: 1 addition & 7 deletions src/nfdump/nfdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ static void usage(char *name) {
name);
} /* usage */

static inline void ClearMasterRecord(master_record_t *record) {
if (record->inPayload) free(record->inPayload);
if (record->outPayload) free(record->outPayload);
memset((void *)record, 0, sizeof(master_record_t));
} // End of ClearMasterRecord

static void PrintSummary(stat_record_t *stat_record, outputParams_t *outputParams) {
static double duration;
uint64_t bps, pps, bpp;
Expand Down Expand Up @@ -658,7 +652,7 @@ int main(int argc, char **argv) {
}
break;
case 'D':
CheckArgLen(optarg, 2);
CheckArgLen(optarg, 64);
nameserver = optarg;
if (!set_nameserver(nameserver)) {
exit(EXIT_FAILURE);
Expand Down
Loading

0 comments on commit f2ddf67

Please sign in to comment.