Skip to content

Commit

Permalink
fix: remove need for strdup operation
Browse files Browse the repository at this point in the history
  • Loading branch information
bduranleau-nr committed Jun 18, 2024
1 parent 97777d0 commit a163988
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions agent/lib_mongodb.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,22 @@ NR_PHP_WRAPPER(nr_mongodb_operation_after) {
.port_path_or_id = NULL,
.database_name = NULL,
};

// tell the compiler to ignore the cast from const char * to char *
// to save having to do a strdup operation
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-qual"
nr_segment_datastore_params_t params = {
.datastore = {
.type = NR_DATASTORE_MONGODB,
},
.operation = nr_strdup (wraprec->extra),
.operation = (char *)wraprec->extra,
.instance = &instance,
.callbacks = {
.backtrace = nr_php_backtrace_callback,
},
};

#pragma GCC diagnostic pop
/*
* We check for the interface all Collection operations extend, rather than
* their specific class. Not all operations have the properties we need but
Expand Down Expand Up @@ -245,7 +250,6 @@ NR_PHP_WRAPPER(nr_mongodb_operation_after) {
nr_php_scope_release(&this_var);
nr_free(instance.host);
nr_free(instance.port_path_or_id);
nr_free(params.operation);
}
NR_PHP_WRAPPER_END

Expand Down

0 comments on commit a163988

Please sign in to comment.