#if HAVE_MC
smx_mailbox_t mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
- (comm.mbox set to NULL when the communication is removed from the mailbox
+ (comm.mbox set to nullptr when the communication is removed from the mailbox
(used as garbage collector)) */
#endif
bool detached = false; /* If detached or not */
void post() override;
double remains();
- sg_host_t host = nullptr; /* The host where the execution takes place. If NULL, then this is a parallel exec (and only surf knows the hosts) */
+ sg_host_t host = nullptr; /* The host where the execution takes place. If nullptr, then this is a parallel exec (and only surf knows the hosts) */
surf_action_t surf_exec = nullptr; /* The Surf execution action encapsulated */
};
* multiple times but only the last one would be used...
*/
if (PJ_type_get_or_null(it.first.c_str(), container->type) == nullptr) {
- PJ_type_variable_new(it.first.c_str(), NULL, container->type);
+ PJ_type_variable_new(it.first.c_str(), nullptr, container->type);
}
}
#endif
virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) {}
- xbt_dynar_t privateLinks_ = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
+ xbt_dynar_t privateLinks_ = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),nullptr);
Link* backbone_ = nullptr;
void *loopback_ = nullptr;
AsClusterDragonfly::~AsClusterDragonfly() {
- if(this->routers_!=NULL){
+ if(this->routers_!=nullptr){
unsigned int i;
for (i=0; i<this->numGroups_*this->numChassisPerGroup_*this->numBladesPerChassis_;i++)
delete(routers_[i]);
}
DragonflyRouter::~DragonflyRouter(){
- if(this->myNodes_!=NULL)
+ if(this->myNodes_!=nullptr)
xbt_free(myNodes_);
- if(this->greenLinks_!=NULL)
+ if(this->greenLinks_!=nullptr)
xbt_free(greenLinks_);
- if(this->blackLinks_!=NULL)
+ if(this->blackLinks_!=nullptr)
xbt_free(blackLinks_);
- if(this->blueLinks_!=NULL)
+ if(this->blueLinks_!=nullptr)
xbt_free(blueLinks_);
}
void AsClusterDragonfly::createLink(char* id, int numlinks, Link** linkup, Link** linkdown){
- *linkup=NULL;
- *linkdown=NULL;
+ *linkup=nullptr;
+ *linkdown=nullptr;
s_sg_platf_link_cbarg_t linkTemplate;
memset(&linkTemplate, 0, sizeof(linkTemplate));
linkTemplate.bandwidth = this->cluster_->bw * numlinks;
unsigned int i, j, k, l;
static int uniqueId = 0;
- char* id = NULL;
+ char* id = nullptr;
Link* linkup, *linkdown;
unsigned int numRouters = this->numGroups_*this->numChassisPerGroup_*this->numBladesPerChassis_;
unsigned int group_;
unsigned int chassis_;
unsigned int blade_;
- surf::Link** blueLinks_=NULL;
- surf::Link** blackLinks_=NULL;
- surf::Link** greenLinks_=NULL;
- surf::Link** myNodes_=NULL;
+ surf::Link** blueLinks_=nullptr;
+ surf::Link** blackLinks_=nullptr;
+ surf::Link** greenLinks_=nullptr;
+ surf::Link** myNodes_=nullptr;
DragonflyRouter(int i, int j, int k);
~DragonflyRouter();
};
unsigned int numLinksBlack_ = 0;
unsigned int numLinksBlue_ = 0;
unsigned int numLinksperLink_ = 1; //fullduplex -> 2, only for local link
- DragonflyRouter** routers_=NULL;
+ DragonflyRouter** routers_=nullptr;
};
}}
explicit AsVivaldi(const char *name);
~AsVivaldi() override;
- xbt_dynar_t getOneLinkRoutes() override {return NULL;};
+ xbt_dynar_t getOneLinkRoutes() override {return nullptr;};
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
};
*/
xbt_dict_t getProperties();
private:
- xbt_dict_t properties_ = NULL;
+ xbt_dict_t properties_ = nullptr;
};
} /* namespace surf */
int coresAmount_ = 1;
simgrid::s4u::Host* host_;
- xbt_dynar_t speedPerPstate_ = NULL; /*< List of supported CPU capacities (pstate related) */
+ xbt_dynar_t speedPerPstate_ = nullptr; /*< List of supported CPU capacities (pstate related) */
int pstate_ = 0; /*< Current pstate (index in the speedPeakList)*/
/* Note (hypervisor): */
- lmm_constraint_t *p_constraintCore=NULL;
- void **p_constraintCoreId=NULL;
+ lmm_constraint_t *p_constraintCore=nullptr;
+ void **p_constraintCoreId=nullptr;
public:
virtual void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values (0 or 1). */
void modified(bool modified);
- CpuTiTgmr *speedIntegratedTrace_ = NULL;/*< Structure with data needed to integrate trace file */
- ActionTiList *actionSet_ = NULL; /*< set with all actions running on cpu */
+ CpuTiTgmr *speedIntegratedTrace_ = nullptr;/*< Structure with data needed to integrate trace file */
+ ActionTiList *actionSet_ = nullptr; /*< set with all actions running on cpu */
double sumPriority_ = 0; /*< the sum of actions' priority that are running on cpu */
double lastUpdate_ = 0; /*< last update of actions' remaining amount done */
IBNode* destination;
NetworkAction *action;
double init_rate;
- ActiveComm() : destination(NULL),action(NULL),init_rate(-1){};
+ ActiveComm() : destination(nullptr),action(nullptr),init_rate(-1){};
~ActiveComm(){};
};
virtual void setBandwidthTrace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */
virtual void setLatencyTrace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */
- tmgr_trace_iterator_t m_stateEvent = NULL;
- s_surf_metric_t m_latency = {1.0,0,NULL};
- s_surf_metric_t m_bandwidth = {1.0,0,NULL};
+ tmgr_trace_iterator_t m_stateEvent = nullptr;
+ s_surf_metric_t m_latency = {1.0,0,nullptr};
+ s_surf_metric_t m_bandwidth = {1.0,0,nullptr};
/* User data */
public:
void *getData() { return userData;}
void setData(void *d) { userData=d;}
private:
- void *userData = NULL;
+ void *userData = nullptr;
/* List of all links */
private:
* @brief Common initializations for the constructors
*/
void initialize(simgrid::surf::Model *model, double cost, bool failed,
- lmm_variable_t var = NULL);
+ lmm_variable_t var = nullptr);
public:
/**
/** @brief Get the state set in which the action is */
ActionList* getStateSet() {return stateSet_;};
- s_xbt_swag_hookup_t stateHookup_ = {NULL,NULL};
+ s_xbt_swag_hookup_t stateHookup_ = {nullptr,nullptr};
simgrid::surf::Model *getModel() {return model_;}
private:
double start_; /**< start time */
- char *category_ = NULL; /**< tracing category for categorized resource utilization monitoring */
+ char *category_ = nullptr; /**< tracing category for categorized resource utilization monitoring */
double cost_;
simgrid::surf::Model *model_;
- void *data_ = NULL; /**< for your convenience */
+ void *data_ = nullptr; /**< for your convenience */
/* LMM */
public:
int routing;
} s_sg_platf_AS_cbarg_t;
-#define SG_PLATF_AS_INITIALIZER {NULL,0}
+#define SG_PLATF_AS_INITIALIZER {nullptr,0}
/********** Routing **********/
void routing_cluster_add_backbone(Link* bb);
memset(&route,0,sizeof(route));
- route.src = sg_netcard_by_name_or_null(A_surfxml_route_src); // tested to not be NULL in start tag
- route.dst = sg_netcard_by_name_or_null(A_surfxml_route_dst); // tested to not be NULL in start tag
+ route.src = sg_netcard_by_name_or_null(A_surfxml_route_src); // tested to not be nullptr in start tag
+ route.dst = sg_netcard_by_name_or_null(A_surfxml_route_dst); // tested to not be nullptr in start tag
route.gw_src = nullptr;
route.gw_dst = nullptr;
route.link_list = new std::vector<Link*>();
s_sg_platf_route_cbarg_t ASroute;
memset(&ASroute,0,sizeof(ASroute));
- ASroute.src = sg_netcard_by_name_or_null(A_surfxml_ASroute_src); // tested to not be NULL in start tag
- ASroute.dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_dst); // tested to not be NULL in start tag
+ ASroute.src = sg_netcard_by_name_or_null(A_surfxml_ASroute_src); // tested to not be nullptr in start tag
+ ASroute.dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_dst); // tested to not be nullptr in start tag
- ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___src); // tested to not be NULL in start tag
- ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___dst); // tested to not be NULL in start tag
+ ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___src); // tested to not be nullptr in start tag
+ ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___dst); // tested to not be nullptr in start tag
ASroute.link_list = new std::vector<Link*>();
s_sg_platf_route_cbarg_t route;
memset(&route,0,sizeof(route));
- route.src = sg_netcard_by_name_or_null(A_surfxml_bypassRoute_src); // tested to not be NULL in start tag
- route.dst = sg_netcard_by_name_or_null(A_surfxml_bypassRoute_dst); // tested to not be NULL in start tag
+ route.src = sg_netcard_by_name_or_null(A_surfxml_bypassRoute_src); // tested to not be nullptr in start tag
+ route.dst = sg_netcard_by_name_or_null(A_surfxml_bypassRoute_dst); // tested to not be nullptr in start tag
route.gw_src = nullptr;
route.gw_dst = nullptr;
route.symmetrical = false;
#ifdef __GXX_ABI_VERSION
int status;
auto res = std::unique_ptr<char, void(*)(void*)>(
- abi::__cxa_demangle(name, NULL, NULL, &status),
+ abi::__cxa_demangle(name, nullptr, nullptr, &status),
std::free
);
if (res != nullptr)
int xbt_backtrace_no_malloc(void **array, int size) {
int i = 0;
for(i=0; i < size; i++)
- array[i] = NULL;
+ array[i] = nullptr;
struct trace_arg arg;
arg .array = array;
if (size >= 1)
_Unwind_Backtrace(backtrace_helper, &arg);
- /* _Unwind_Backtrace on IA-64 seems to put NULL address above
+ /* _Unwind_Backtrace on IA-64 seems to put nullptr address above
_start. Fix it up here. */
- if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL)
+ if (arg.cnt > 1 && arg.array[arg.cnt - 1] == nullptr)
--arg.cnt;
return arg.cnt != -1 ? arg.cnt : 0;
}
while (!found) {
long int first, last;
- if (fgets(maps_buff, 512, maps) == NULL)
+ if (fgets(maps_buff, 512, maps) == nullptr)
break;
if (i == 0) {
maps_buff[strlen(maps_buff) - 1] = '\0';
int xbt_libunwind_backtrace(void** bt, int size){
int i = 0;
for(i=0; i < size; i++)
- bt[i] = NULL;
+ bt[i] = nullptr;
i=0;
#include "xbt/dynar.h"
/* collection of all suites */
-static xbt_dynar_t _xbt_test_suites = NULL;
+static xbt_dynar_t _xbt_test_suites = nullptr;
/* global statistics */
static int _xbt_test_nb_tests = 0;
static int _xbt_test_test_failed = 0;
static int _xbt_test_suite_disabled = 0;
/* Context */
-xbt_test_unit_t _xbt_test_current_unit = NULL;
+xbt_test_unit_t _xbt_test_current_unit = nullptr;
/* test suite test log */
typedef struct s_xbt_test_log {
if (log)
fprintf(stderr, " log %p(%s:%d)=%s\n", log, log->file, log->line, log->text);
else
- fprintf(stderr, " log=NULL\n");
+ fprintf(stderr, " log=nullptr\n");
}
/* test suite test check */
xbt_dynar_foreach(test->logs, it_log, log)
xbt_test_log_dump(log);
} else
- fprintf(stderr, " test=NULL\n");
+ fprintf(stderr, " test=nullptr\n");
}
/* test suite test unit */
xbt_dynar_foreach(unit->tests, it_test, test)
xbt_test_test_dump(test);
} else {
- fprintf(stderr, " unit=NULL\n");
+ fprintf(stderr, " unit=nullptr\n");
}
}
{
xbt_test_suite_t suite = *(xbt_test_suite_t *) s;
- if (suite == NULL)
+ if (suite == nullptr)
return;
xbt_dynar_free(&suite->units);
free(suite->title);
va_start(ap, fmt);
bufname = bvprintf(fmt, ap);
va_end(ap);
- suite = xbt_test_suite_new(name, bufname, NULL);
+ suite = xbt_test_suite_new(name, bufname, nullptr);
free(bufname);
return suite;
xbt_dynar_foreach(suite->units, it_unit, unit)
xbt_test_unit_dump(unit);
} else {
- fprintf(stderr, "TESTSUITE IS NULL!\n");
+ fprintf(stderr, "TESTSUITE IS nullptr!\n");
}
}
va_end(ap);
unit->name = (char *) name;
unit->func = func;
- unit->file = NULL;
+ unit->file = nullptr;
unit->line = 0;
unit->enabled = 1;
unit->tests = xbt_dynar_new(sizeof(xbt_test_test_t), xbt_test_test_free);
int first = 1; /* for result pretty printing */
- if (suite == NULL)
+ if (suite == nullptr)
return 0;
/* suite title pretty-printing */
fprintf(stderr, ".... skip\n"); /* shouldn't happen, but I'm a bit lost with this logic */
}
xbt_dynar_foreach(unit->tests, it_test, test) {
- file = (test->file != NULL ? test->file : unit->file);
+ file = (test->file != nullptr ? test->file : unit->file);
line = (test->line != 0 ? test->line : unit->line);
fprintf(stderr, " %s: %s [%s:%d]\n", (test->ignored ? " SKIP" : (test->expected_failure
? (test-> failed ? "EFAIL" : "EPASS") : (test->failed ? " FAIL" : " PASS"))),test->title, file, line);
if ((test->expected_failure && !test->failed) || (!test->expected_failure && test->failed)) {
xbt_dynar_foreach(test->logs, it_log, log) {
- file = (log->file != NULL ? log->file : file);
+ file = (log->file != nullptr ? log->file : file);
line = (log->line != 0 ? log->line : line);
fprintf(stderr, " %s:%d: %s\n", file, line, log->text);
}
*/
xbt_dict_t xbt_dict_new(void)
{
- xbt_dict_t dict = xbt_dict_new_homogeneous(NULL);
+ xbt_dict_t dict = xbt_dict_new_homogeneous(nullptr);
dict->homogeneous = 0;
return dict;
*/
xbt_dict_t xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn)
{
- if (dict_elm_mallocator == NULL)
+ if (dict_elm_mallocator == nullptr)
xbt_dict_preinit();
xbt_dict_t dict;
// if ( *dict ) xbt_dict_dump_sizes(*dict);
- if (dict != NULL && *dict != NULL) {
+ if (dict != nullptr && *dict != nullptr) {
table_size = (*dict)->table_size;
table = (*dict)->table;
/* Warning: the size of the table is 'table_size+1'...
* This is because table_size is used as a binary mask in xbt_dict_rehash */
for (i = 0; (*dict)->count && i <= table_size; i++) {
current = table[i];
- while (current != NULL) {
+ while (current != nullptr) {
previous = current;
current = current->next;
xbt_dictelm_free(*dict, previous);
}
xbt_free(table);
xbt_free(*dict);
- *dict = NULL;
+ *dict = nullptr;
}
}
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
- xbt_dictelm_t current, previous = NULL;
+ xbt_dictelm_t current, previous = nullptr;
XBT_CDEBUG(xbt_dict, "ADD %.*s hash = %u, size = %d, & = %u", key_len, key, hash_code,
dict->table_size, hash_code & dict->table_size);
current = dict->table[hash_code & dict->table_size];
- while (current != NULL && (hash_code != current->hash_code || key_len != current->key_len
+ while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
|| memcmp(key, current->key, key_len))) {
previous = current;
current = current->next;
}
- if (current == NULL) {
+ if (current == nullptr) {
/* this key doesn't exist yet */
current = xbt_dictelm_new(dict, key, key_len, hash_code, data, free_ctn);
dict->count++;
- if (previous == NULL) {
+ if (previous == nullptr) {
dict->table[hash_code & dict->table_size] = current;
dict->fill++;
if ((dict->fill * 100) / (dict->table_size + 1) > MAX_FILL_PERCENT)
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
- while (current != NULL && (hash_code != current->hash_code || key_len != current->key_len
+ while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
|| memcmp(key, current->key, key_len))) {
current = current->next;
}
- if (current == NULL)
+ if (current == nullptr)
THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
return current->content;
}
-/** @brief like xbt_dict_get_ext(), but returning NULL when not found */
+/** @brief like xbt_dict_get_ext(), but returning nullptr when not found */
void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key, int key_len)
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
- while (current != NULL && (hash_code != current->hash_code || key_len != current->key_len
+ while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
|| memcmp(key, current->key, key_len))) {
current = current->next;
}
- if (current == NULL)
- return NULL;
+ if (current == nullptr)
+ return nullptr;
return current->content;
}
/**
* @brief retrieve the key associated to that object. Warning, that's a linear search
*
- * Returns NULL if the object cannot be found
+ * Returns nullptr if the object cannot be found
*/
char *xbt_dict_get_key(xbt_dict_t dict, const void *data)
{
for (int i = 0; i <= dict->table_size; i++) {
xbt_dictelm_t current = dict->table[i];
- while (current != NULL) {
+ while (current != nullptr) {
if (current->content == data)
return current->key;
current = current->next;
}
}
- return NULL;
+ return nullptr;
}
/** @brief retrieve the key associated to that xbt_dictelm_t. */
* \return the data that we are looking for
*
* Search the given \a key. Throws not_found_error when not found.
- * Check xbt_dict_get_or_null() for a version returning NULL without exception when not found.
+ * Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.
*/
void *xbt_dict_get(xbt_dict_t dict, const char *key)
{
* \return the s_xbt_dictelm_t that we are looking for
*
* Search the given \a key. Throws not_found_error when not found.
- * Check xbt_dict_get_or_null() for a version returning NULL without exception when not found.
+ * Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.
*/
xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
{
xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
- if (current == NULL)
+ if (current == nullptr)
THROWF(not_found_error, 0, "key %s not found", key);
return current;
}
/**
- * \brief like xbt_dict_get(), but returning NULL when not found
+ * \brief like xbt_dict_get(), but returning nullptr when not found
*/
void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
{
xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
- if (current == NULL)
- return NULL;
+ if (current == nullptr)
+ return nullptr;
return current->content;
}
/**
- * \brief like xbt_dict_get_elm(), but returning NULL when not found
+ * \brief like xbt_dict_get_elm(), but returning nullptr when not found
*/
xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
{
unsigned int hash_code = xbt_str_hash(key);
xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
- while (current != NULL && (hash_code != current->hash_code || strcmp(key, current->key)))
+ while (current != nullptr && (hash_code != current->hash_code || strcmp(key, current->key)))
current = current->next;
return current;
}
void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len)
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
- xbt_dictelm_t previous = NULL;
+ xbt_dictelm_t previous = nullptr;
xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
- while (current != NULL && (hash_code != current->hash_code || key_len != current->key_len
+ while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
|| strncmp(key, current->key, key_len))) {
previous = current; /* save the previous node */
current = current->next;
}
- if (current == NULL)
+ if (current == nullptr)
THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
- if (previous != NULL) {
+ if (previous != nullptr) {
previous->next = current->next;
} else {
dict->table[hash_code & dict->table_size] = current->next;
return;
for (int i = 0; i <= dict->table_size; i++) {
- xbt_dictelm_t previous = NULL;
+ xbt_dictelm_t previous = nullptr;
xbt_dictelm_t current = dict->table[i];
- while (current != NULL) {
+ while (current != nullptr) {
previous = current;
current = current->next;
xbt_dictelm_free(dict, previous);
}
- dict->table[i] = NULL;
+ dict->table[i] = nullptr;
}
dict->count = 0;
* \param dict the exibitionist
* \param output a function to dump each data in the tree (check @ref xbt_dict_dump_output_string)
*
- * Outputs the content of the structure. (for debugging purpose). \a output is a function to output the data. If NULL,
+ * Outputs the content of the structure. (for debugging purpose). \a output is a function to output the data. If nullptr,
* data won't be displayed.
*/
void xbt_dict_dump(xbt_dict_t dict, void_f_pvoid_t output)
int i;
xbt_dictelm_t element;
printf("Dict %p:\n", dict);
- if (dict != NULL) {
+ if (dict != nullptr) {
for (i = 0; i < dict->table_size; i++) {
element = dict->table[i];
if (element) {
printf("[\n");
- while (element != NULL) {
+ while (element != nullptr) {
printf(" %s -> '", element->key);
- if (output != NULL) {
+ if (output != nullptr) {
output(element->content);
}
printf("'\n");
}
}
-xbt_dynar_t all_sizes = NULL;
+xbt_dynar_t all_sizes = nullptr;
/** @brief shows some debugging info about the bucklet repartition */
void xbt_dict_dump_sizes(xbt_dict_t dict)
{
printf("\n");
return;
}
- xbt_dynar_t sizes = xbt_dynar_new(sizeof(int), NULL);
+ xbt_dynar_t sizes = xbt_dynar_new(sizeof(int), nullptr);
for (int i = 0; i < dict->table_size; i++) {
xbt_dictelm_t element = dict->table[i];
size = 0;
if (element) {
- while (element != NULL) {
+ while (element != nullptr) {
size++;
element = element->next;
}
}
}
if (!all_sizes)
- all_sizes = xbt_dynar_new(sizeof(int), NULL);
+ all_sizes = xbt_dynar_new(sizeof(int), nullptr);
xbt_dynar_foreach(sizes, count, size) {
/* Copy values of this one into all_sizes */
*/
void xbt_dict_preinit(void)
{
- if (dict_elm_mallocator == NULL)
+ if (dict_elm_mallocator == nullptr)
dict_elm_mallocator = xbt_mallocator_new(
256, dict_elm_mallocator_new_f, dict_elm_mallocator_free_f,
dict_elm_mallocator_reset_f);
- if (dict_het_elm_mallocator == NULL)
+ if (dict_het_elm_mallocator == nullptr)
dict_het_elm_mallocator = xbt_mallocator_new(
256, dict_het_elm_mallocator_new_f, dict_het_elm_mallocator_free_f,
dict_het_elm_mallocator_reset_f);
*/
void xbt_dict_postexit(void)
{
- if (dict_elm_mallocator != NULL) {
+ if (dict_elm_mallocator != nullptr) {
xbt_mallocator_free(dict_elm_mallocator);
- dict_elm_mallocator = NULL;
+ dict_elm_mallocator = nullptr;
xbt_mallocator_free(dict_het_elm_mallocator);
- dict_het_elm_mallocator = NULL;
+ dict_het_elm_mallocator = nullptr;
}
if (all_sizes) {
unsigned int count;
static void fill(xbt_dict_t * head, int homogeneous)
{
- void_f_pvoid_t free_f = homogeneous ? NULL : &free;
+ void_f_pvoid_t free_f = homogeneous ? nullptr : &free;
xbt_test_add("Fill in the dictionnary");
char *found = (char*) xbt_dict_get(head, key);
xbt_test_log("Found %s", found);
if (data) {
- xbt_test_assert(found, "data do not match expectations: found NULL while searching for %s", data);
+ xbt_test_assert(found, "data do not match expectations: found nullptr while searching for %s", data);
if (found)
xbt_test_assert(!strcmp(data, found), "data do not match expectations: found %s while searching for %s",
found, data);
} else {
- xbt_test_assert(!found, "data do not match expectations: found %s while searching for NULL", found);
+ xbt_test_assert(!found, "data do not match expectations: found %s while searching for nullptr", found);
}
}
static void traverse(xbt_dict_t head)
{
- xbt_dict_cursor_t cursor = NULL;
+ xbt_dict_cursor_t cursor = nullptr;
char *key;
char *data;
int i = 0;
}
xbt_ex_t e;
-xbt_dict_t head = NULL;
+xbt_dict_t head = nullptr;
char *data;
static void basic_test(int homogeneous)
}
xbt_dict_free(&head);
- free_f = homogeneous ? NULL : &free;
+ free_f = homogeneous ? nullptr : &free;
xbt_test_add("Traverse the full dictionary");
fill(&head, homogeneous);
remove_test(1);
}
-XBT_TEST_UNIT("nulldata", test_dict_nulldata, "NULL data management")
+XBT_TEST_UNIT("nulldata", test_dict_nulldata, "nullptr data management")
{
fill(&head, 1);
- xbt_test_add("Store NULL under 'null'");
- xbt_dict_set(head, "null", NULL, NULL);
- search_ext(head, "null", NULL);
+ xbt_test_add("Store nullptr under 'null'");
+ xbt_dict_set(head, "null", nullptr, nullptr);
+ search_ext(head, "null", nullptr);
xbt_test_add("Check whether I see it while traversing...");
{
- xbt_dict_cursor_t cursor = NULL;
+ xbt_dict_cursor_t cursor = nullptr;
char *key;
int found = 0;
if (!strcmp(key, "null"))
found = 1;
}
- xbt_test_assert(found, "the key 'null', associated to NULL is not found");
+ xbt_test_assert(found, "the key 'null', associated to nullptr is not found");
}
xbt_dict_free(&head);
}
XBT_TEST_UNIT("crash", test_dict_crash, "Crash test")
{
- xbt_dict_t head = NULL;
+ xbt_dict_t head = nullptr;
int i, j, k;
char *key;
- srand((unsigned int) time(NULL));
+ srand((unsigned int) time(nullptr));
for (i = 0; i < 10; i++) {
xbt_test_add("CRASH test number %d (%d to go)", i + 1, 10 - i - 1);
head = xbt_dict_new();
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
for (j = 0; j < 1000; j++) {
- char *data = NULL;
+ char *data = nullptr;
key = (char*) xbt_malloc(SIZEOFKEY);
do {
key[k] = '\0';
/* printf("[%d %s]\n",j,key); */
data = (char*) xbt_dict_get_or_null(head, key);
- } while (data != NULL);
+ } while (data != nullptr);
xbt_dict_set(head, key, key, &free);
data = (char*) xbt_dict_get(head, key);
xbt_test_add("Insert elements");
int i;
for (i = 0; i < count; ++i)
- xbt_dict_set_ext(dict, (char*) &i, sizeof(i), (void*) (intptr_t) i, NULL);
+ xbt_dict_set_ext(dict, (char*) &i, sizeof(i), (void*) (intptr_t) i, nullptr);
xbt_test_assert(xbt_dict_size(dict) == (unsigned) count, "Bad number of elements in the dictionnary");
xbt_test_add("Check elements");
static inline void _sanity_check_dynar(xbt_dynar_t dynar)
{
- xbt_assert(dynar, "dynar is NULL");
+ xbt_assert(dynar, "dynar is nullptr");
}
static inline void _sanity_check_idx(int idx)
/** @brief Constructor
*
* \param elmsize size of each element in the dynar
- * \param free_f function to call each time we want to get rid of an element (or NULL if nothing to do).
+ * \param free_f function to call each time we want to get rid of an element (or nullptr if nothing to do).
*
* Creates a new dynar. If a free_func is provided, the elements have to be pointer of pointer. That is to say that
* dynars can contain either base types (int, char, double, etc) or pointer of pointers (struct **).
dynar->size = 0;
dynar->used = 0;
dynar->elmsize = elmsize;
- dynar->data = NULL;
+ dynar->data = nullptr;
dynar->free_f = free_f;
return dynar;
xbt_dynar_t d = *dynar;
free(d->data);
free(d);
- *dynar = NULL;
+ *dynar = nullptr;
}
}
/** @brief Remove a slice of the dynar, sliding the rest of the values to the left
*
* This function removes an n-sized slice that starts at element idx. It is equivalent to xbt_dynar_remove_at with a
- * NULL object argument if n equals to 1.
+ * nullptr object argument if n equals to 1.
*
* Each of the removed elements is freed using the free_f function passed at dynar creation.
*/
*/
void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int *const cursor)
{
- xbt_dynar_remove_at(dynar, (*cursor)--, NULL);
+ xbt_dynar_remove_at(dynar, (*cursor)--, nullptr);
}
/** @brief Sorts a dynar according to the function <tt>compar_fn</tt>
xbt_free(tmp);
}
-/** @brief Transform a dynar into a NULL terminated array.
+/** @brief Transform a dynar into a nullptr terminated array.
*
* \param dynar the dynar to transform
* \return pointer to the first element of the array
if((!d1) && (!d2)) return 0;
if((!d1) || (!d2))
{
- XBT_DEBUG("NULL dynar d1=%p d2=%p",d1,d2);
+ XBT_DEBUG("nullptr dynar d1=%p d2=%p",d1,d2);
xbt_dynar_free(&d2);
return 1;
}
int *iptr;
xbt_test_add("==== Traverse the empty dynar");
- d = xbt_dynar_new(sizeof(int), NULL);
+ d = xbt_dynar_new(sizeof(int), nullptr);
xbt_dynar_foreach(d, cursor, i) {
xbt_die( "Damnit, there is something in the empty dynar");
}
xbt_test_add("==== Push %d int, set them again 3 times, traverse them, shift them", NB_ELEM);
/* Populate_ints [doxygen cruft] */
/* 1. Populate the dynar */
- d = xbt_dynar_new(sizeof(int), NULL);
+ d = xbt_dynar_new(sizeof(int), nullptr);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt); /* This is faster (and possible only with scalars) */
/* xbt_dynar_push(d,&cpt); This would also work */
/* in your code is naturally the way to go outside a regression test */
xbt_test_add("==== Unshift/pop %d int", NB_ELEM);
- d = xbt_dynar_new(sizeof(int), NULL);
+ d = xbt_dynar_new(sizeof(int), nullptr);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_unshift(d, &cpt);
XBT_DEBUG("Push %d, length=%lu", cpt, xbt_dynar_length(d));
/* in your code is naturally the way to go outside a regression test */
xbt_test_add ("==== Push %d int, insert 1000 int in the middle, shift everything", NB_ELEM);
- d = xbt_dynar_new(sizeof(int), NULL);
+ d = xbt_dynar_new(sizeof(int), nullptr);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt);
XBT_DEBUG("Push %d, length=%lu", cpt, xbt_dynar_length(d));
/* in your code is naturally the way to go outside a regression test */
xbt_test_add("==== Push %d int, remove 2000-4000. free the rest", NB_ELEM);
- d = xbt_dynar_new(sizeof(int), NULL);
+ d = xbt_dynar_new(sizeof(int), nullptr);
for (cpt = 0; cpt < NB_ELEM; cpt++)
xbt_dynar_push_as(d, int, cpt);
/*******************************************************************************/
XBT_TEST_UNIT("insert",test_dynar_insert,"Using the xbt_dynar_insert and xbt_dynar_remove functions")
{
- xbt_dynar_t d = xbt_dynar_new(sizeof(unsigned int), NULL);
+ xbt_dynar_t d = xbt_dynar_new(sizeof(unsigned int), nullptr);
unsigned int cursor;
int cpt;
/* ********************* */
xbt_test_add("==== Insert %d int in reverse order, traverse them, remove them",NB_ELEM);
- d = xbt_dynar_new(sizeof(int), NULL);
+ d = xbt_dynar_new(sizeof(int), nullptr);
for (cpt = NB_ELEM-1; cpt >=0; cpt--) {
xbt_dynar_replace(d, cpt, &cpt);
xbt_test_log("Push %d, length=%lu", cpt, xbt_dynar_length(d));
double d1, d2;
xbt_test_add("==== Traverse the empty dynar");
- d = xbt_dynar_new(sizeof(int), NULL);
+ d = xbt_dynar_new(sizeof(int), nullptr);
xbt_dynar_foreach(d, cursor, cpt) {
xbt_test_assert(FALSE, "Damnit, there is something in the empty dynar");
}
/* in your code is naturally the way to go outside a regression test */
xbt_test_add("==== Push/shift 5000 doubles");
- d = xbt_dynar_new(sizeof(double), NULL);
+ d = xbt_dynar_new(sizeof(double), nullptr);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
xbt_dynar_push(d, &d1);
/* in your code is naturally the way to go outside a regression test */
xbt_test_add("==== Unshift/pop 5000 doubles");
- d = xbt_dynar_new(sizeof(double), NULL);
+ d = xbt_dynar_new(sizeof(double), nullptr);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
xbt_dynar_unshift(d, &d1);
/* in your code is naturally the way to go outside a regression test */
xbt_test_add("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
- d = xbt_dynar_new(sizeof(double), NULL);
+ d = xbt_dynar_new(sizeof(double), nullptr);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
xbt_dynar_push(d, &d1);
/* in your code is naturally the way to go outside a regression test */
xbt_test_add("==== Push 5000 double, remove 2000-4000. free the rest");
- d = xbt_dynar_new(sizeof(double), NULL);
+ d = xbt_dynar_new(sizeof(double), nullptr);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
xbt_dynar_push(d, &d1);
FILE *xbt_action_fp;
-xbt_dict_t xbt_action_funs = NULL;
-xbt_dict_t xbt_action_queues = NULL;
+xbt_dict_t xbt_action_funs = nullptr;
+xbt_dict_t xbt_action_queues = nullptr;
-static char *action_line = NULL;
+static char *action_line = nullptr;
static size_t action_len = 0;
int is_replay_active = 0 ;
{
xbt_replay_reader_t res = xbt_new0(s_xbt_replay_reader_t,1);
res->fp = fopen(filename, "r");
- xbt_assert(res->fp != NULL, "Cannot open %s: %s", filename, strerror(errno));
+ xbt_assert(res->fp != nullptr, "Cannot open %s: %s", filename, strerror(errno));
res->filename = xbt_strdup(filename);
return res;
}
//XBT_INFO("got from trace: %s",reader->line);
reader->linenum++;
if (read==-1)
- return NULL; /* end of file */
+ return nullptr; /* end of file */
char *comment = strchr(reader->line, '#');
- if (comment != NULL)
+ if (comment != nullptr)
*comment = '\0';
- xbt_str_trim(reader->line, NULL);
+ xbt_str_trim(reader->line, nullptr);
if (reader->line[0] == '\0')
return xbt_replay_reader_get(reader); /* Get next line */
fclose((*reader)->fp);
free((*reader)->line);
free(*reader);
- *reader=NULL;
+ *reader=nullptr;
}
/**
void xbt_replay_action_register(const char *action_name, action_fun function)
{
char* lowername = str_tolower (action_name);
- xbt_dict_set(xbt_action_funs, lowername, (void*) function, NULL);
+ xbt_dict_set(xbt_action_funs, lowername, (void*) function, nullptr);
xbt_free(lowername);
}
if (xbt_action_funs)
return 0;
is_replay_active = 1;
- xbt_action_funs = xbt_dict_new_homogeneous(NULL);
- xbt_action_queues = xbt_dict_new_homogeneous(NULL);
+ xbt_action_funs = xbt_dict_new_homogeneous(nullptr);
+ xbt_action_queues = xbt_dict_new_homogeneous(nullptr);
return 1;
}
xbt_dict_free(&xbt_action_queues);
xbt_dict_free(&xbt_action_funs);
free(action_line);
- xbt_action_queues = NULL;
- xbt_action_funs = NULL;
- action_line = NULL;
+ xbt_action_queues = nullptr;
+ xbt_action_funs = nullptr;
+ action_line = nullptr;
}
/**
catch(xbt_ex& e) {
xbt_die("Replay error :\n %s", e.what());
}
- for (i=0;evt[i]!= NULL;i++)
+ for (i=0;evt[i]!= nullptr;i++)
free(evt[i]);
free(evt);
}
static char **action_get_action(char *name)
{
- xbt_dynar_t evt = NULL;
- char *evtname = NULL;
+ xbt_dynar_t evt = nullptr;
+ char *evtname = nullptr;
xbt_dynar_t myqueue = (xbt_dynar_t) xbt_dict_get_or_null(xbt_action_queues, name);
- if (myqueue == NULL || xbt_dynar_is_empty(myqueue)) { // nothing stored for me. Read the file further
- if (xbt_action_fp == NULL) { // File closed now. There's nothing more to read. I'm out of here
+ if (myqueue == nullptr || xbt_dynar_is_empty(myqueue)) { // nothing stored for me. Read the file further
+ if (xbt_action_fp == nullptr) { // File closed now. There's nothing more to read. I'm out of here
goto todo_done;
}
// Read lines until I reach something for me (which breaks in loop body)
while (xbt_getline(&action_line, &action_len, xbt_action_fp) != -1) {
// cleanup and split the string I just read
char *comment = strchr(action_line, '#');
- if (comment != NULL)
+ if (comment != nullptr)
*comment = '\0';
- xbt_str_trim(action_line, NULL);
+ xbt_str_trim(action_line, nullptr);
if (action_line[0] == '\0')
continue;
/* we cannot split in place here because we parse&store several lines for
// Else, I have to store it for the relevant colleague
xbt_dynar_t otherqueue =
(xbt_dynar_t) xbt_dict_get_or_null(xbt_action_queues, evtname);
- if (otherqueue == NULL) { // Damn. Create the queue of that guy
+ if (otherqueue == nullptr) { // Damn. Create the queue of that guy
otherqueue = xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
- xbt_dict_set(xbt_action_queues, evtname, otherqueue, NULL);
+ xbt_dict_set(xbt_action_queues, evtname, otherqueue, nullptr);
}
xbt_dynar_push(otherqueue, &evt);
}
// I did all my actions for me in the file (either I closed the file, or a colleague did)
// Let's cleanup before leaving
todo_done:
- if (myqueue != NULL) {
+ if (myqueue != nullptr) {
xbt_dynar_free(&myqueue);
xbt_dict_remove(xbt_action_queues, name);
}
- return NULL;
+ return nullptr;
}
/** @brief Strip whitespace (or other characters) from the end of a string.
*
* Strips the whitespaces from the end of s.
- * By default (when char_list=NULL), these characters get stripped:
+ * By default (when char_list=nullptr), these characters get stripped:
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
* - "\n" (ASCII 10 (0x0A)) line feed.
* - "\r" (ASCII 13 (0x0D)) carriage return.
- * - "\0" (ASCII 0 (0x00)) NULL.
+ * - "\0" (ASCII 0 (0x00)) nullptr.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*
* @param s The string to strip. Modified in place.
/** @brief Strip whitespace (or other characters) from the beginning of a string.
*
* Strips the whitespaces from the begining of s.
- * By default (when char_list=NULL), these characters get stripped:
+ * By default (when char_list=nullptr), these characters get stripped:
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
* - "\n" (ASCII 10 (0x0A)) line feed.
* - "\r" (ASCII 13 (0x0D)) carriage return.
- * - "\0" (ASCII 0 (0x00)) NULL.
+ * - "\0" (ASCII 0 (0x00)) nullptr.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*
* @param s The string to strip. Modified in place.
/** @brief Strip whitespace (or other characters) from the end and the begining of a string.
*
* Strips the whitespaces from both the beginning and the end of s.
- * By default (when char_list=NULL), these characters get stripped:
+ * By default (when char_list=nullptr), these characters get stripped:
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
* - "\n" (ASCII 10 (0x0A)) line feed.
* - "\r" (ASCII 13 (0x0D)) carriage return.
- * - "\0" (ASCII 0 (0x00)) NULL.
+ * - "\0" (ASCII 0 (0x00)) nullptr.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*
* @param s The string to strip.
* @param s: the string to split
* @param sep: a string of all chars to consider as separator.
*
- * By default (with sep=NULL), these characters are used as separator:
+ * By default (with sep=nullptr), these characters are used as separator:
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
* - "\n" (ASCII 10 (0x0A)) line feed.
* - "\r" (ASCII 13 (0x0D)) carriage return.
- * - "\0" (ASCII 0 (0x00)) NULL.
+ * - "\0" (ASCII 0 (0x00)) nullptr.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*/
xbt_dynar_t xbt_str_split(const char *s, const char *sep)
//get the start of the first occurence of the substring
q = strstr(p, sep);
//if substring was not found add the entire string
- if (NULL == q) {
+ if (nullptr == q) {
v = strlen(p);
to_push = (char*) xbt_malloc(v + 1);
memcpy(to_push, p, v);
* pushes the address of each chunk in the resulting dynar. Yes, that's uneven. Yes, that's gory. But that's efficient.
*/
xbt_dynar_t xbt_str_split_quoted_in_place(char *s) {
- xbt_dynar_t res = xbt_dynar_new(sizeof(char *), NULL);
+ xbt_dynar_t res = xbt_dynar_new(sizeof(char *), nullptr);
char *beg, *end; /* pointers around the parsed chunk */
int in_simple_quote = 0, in_double_quote = 0;
int done = 0;
/** @brief Join a set of strings as a single string
*
- * The parameter must be a NULL-terminated array of chars,
+ * The parameter must be a nullptr-terminated array of chars,
* just like xbt_dynar_to_array() produces
*/
char *xbt_str_join_array(const char *const *strs, const char *sep)
long int xbt_str_parse_int(const char* str, const char* error_msg)
{
char *endptr;
- if (str == NULL || str[0] == '\0')
+ if (str == nullptr || str[0] == '\0')
THROWF(arg_error, 0, error_msg, str);
long int res = strtol(str, &endptr, 10);
double xbt_str_parse_double(const char* str, const char* error_msg)
{
char *endptr;
- if (str == NULL || str[0] == '\0')
+ if (str == nullptr || str[0] == '\0')
THROWF(arg_error, 0, error_msg, str);
double res = strtod(str, &endptr);
test_parse_ok(xbt_str_parse_int, "Parse -1 as an int", rint, "-1", -1);
test_parse_error(xbt_str_parse_int, "Parse int + noise", rint, "342 cruft");
- test_parse_error(xbt_str_parse_int, "Parse NULL as an int", rint, NULL);
+ test_parse_error(xbt_str_parse_int, "Parse nullptr as an int", rint, nullptr);
test_parse_error(xbt_str_parse_int, "Parse '' as an int", rint, "");
test_parse_error(xbt_str_parse_int, "Parse cruft as an int", rint, "cruft");
test_parse_ok(xbt_str_parse_double, "Parse -1 as a double", rdouble, "-1", -1);
test_parse_error(xbt_str_parse_double, "Parse double + noise", rdouble, "342 cruft");
- test_parse_error(xbt_str_parse_double, "Parse NULL as a double", rdouble, NULL);
+ test_parse_error(xbt_str_parse_double, "Parse nullptr as a double", rdouble, nullptr);
test_parse_error(xbt_str_parse_double, "Parse '' as a double", rdouble, "");
test_parse_error(xbt_str_parse_double, "Parse cruft as a double", rdouble, "cruft");
}