Skip to content

Commit

Permalink
Add free_bcc_memory to BPFModule (iovisor#2147)
Browse files Browse the repository at this point in the history
Some users uses `BPFModule` directly instead of C++ / Python API, and
they would like to have similar interface of free BCC `.text` memory
  • Loading branch information
palmtenor authored and yonghong-song committed Jan 16, 2019
1 parent b0bf04a commit 4c5509f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cc/bpf_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "common.h"
#include "bcc_debug.h"
#include "bcc_elf.h"
#include "frontends/b/loader.h"
#include "frontends/clang/loader.h"
#include "frontends/clang/b_frontend_action.h"
Expand Down Expand Up @@ -141,6 +142,10 @@ BPFModule::~BPFModule() {
ts_->DeletePrefix(Path({id_}));
}

int BPFModule::free_bcc_memory() {
return bcc_free_memory();
}

// load an entire c file as a module
int BPFModule::load_cfile(const string &file, bool in_memory, const char *cflags[], int ncflags) {
ClangLoader clang_loader(&*ctx_, flags_);
Expand Down
1 change: 1 addition & 0 deletions src/cc/bpf_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class BPFModule {
BPFModule(unsigned flags, TableStorage *ts = nullptr, bool rw_engine_enabled = true,
const std::string &maps_ns = "");
~BPFModule();
int free_bcc_memory();
int load_b(const std::string &filename, const std::string &proto_filename);
int load_c(const std::string &filename, const char *cflags[], int ncflags);
int load_string(const std::string &text, const char *cflags[], int ncflags);
Expand Down

0 comments on commit 4c5509f

Please sign in to comment.