unsigned int nb_elem = xbt_dynar_length(s1);
for (unsigned int cursor = 0; cursor < nb_elem; cursor++) {
- int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
- int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
+ const int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
+ const int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
if(*iptr1 != *iptr2)
return 1;
}
static void new_state(char* id, int src){
char* saveptr = NULL; // for strtok_r()
char* id_copy = xbt_strdup(id);
- char* first_part = strtok_r(id_copy, "_", &saveptr);
+ const char* first_part = strtok_r(id_copy, "_", &saveptr);
int type = 0 ; // -1=initial state; 0=intermediate state; 1=final state
if(strcmp(first_part,"accept")==0){
type = 1;
}else{
- char* second_part = strtok_r(NULL, "_", &saveptr);
+ const char* second_part = strtok_r(NULL, "_", &saveptr);
if(strcmp(second_part,"init")==0){
type = -1;
}
void *xbt_dict_get_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];
+ const s_xbt_dictelm* current = dict->table[hash_code & dict->table_size];
while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
|| memcmp(key, current->key, key_len))) {
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];
+ const s_xbt_dictelm* current = dict->table[hash_code & dict->table_size];
while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
|| memcmp(key, current->key, key_len))) {
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];
+ const s_xbt_dictelm* current = dict->table[i];
while (current != nullptr) {
if (current->content == data)
return current->key;
*/
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);
+ const s_xbt_dictelm* current = xbt_dict_get_elm_or_null(dict, key);
if (current == nullptr)
return nullptr;
*/
inline int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t * cursor, char **key, void **data)
{
- xbt_dictelm_t current;
+ const struct s_xbt_dictelm* current;
XBT_CDEBUG(xbt_dict_cursor, "xbt_dict_get_or_free");
/* RETRIEVE */
INFO("Search 123");
- char* data = (char*)xbt_dict_get(head, "123");
+ const char* data = (char*)xbt_dict_get(head, "123");
REQUIRE((data && strcmp("123", data) == 0));
search_not_found(head, "Can't be found");
INFO("using 1000 elements with " << SIZEOFKEY << " chars long randomized keys.");
xbt_dict_t head = xbt_dict_new_homogeneous(free);
for (int j = 0; j < 1000; j++) {
- char* data = nullptr;
+ const char* data = nullptr;
char* key = (char*)xbt_malloc(SIZEOFKEY);
do {
static inline void _xbt_dynar_get_elm(void *const dst, const xbt_dynar_t dynar, const unsigned long idx)
{
- void *const elm = _xbt_dynar_elm(dynar, idx);
-
+ const void* const elm = _xbt_dynar_elm(dynar, idx);
memcpy(dst, elm, dynar->elmsize);
}
const unsigned long elmsize = (*d1)->elmsize;
- void *ptr = _xbt_dynar_elm((*d2), 0);
+ const void* ptr = _xbt_dynar_elm((*d2), 0);
_xbt_dynar_resize(*d1, (*d1)->size + (*d2)->size);
void *elm = _xbt_dynar_elm((*d1), (*d1)->used);
/* 2. Traverse manually the dynar */
for (int i = 0; i < NB_ELEM; i++) {
- int* iptr = (int*)xbt_dynar_get_ptr(d, i);
+ const int* iptr = (int*)xbt_dynar_get_ptr(d, i);
REQUIRE(i == *iptr); // The retrieved value is not the same than the injected one
}
return;
try {
with_nested->rethrow_nested();
- }
- catch (std::exception& nested_exception) {
+ } catch (const std::exception& nested_exception) {
log_exception(prio, "Caused by", nested_exception);
}
// We could catch nested_exception or WithContextException but we don't bother:
}
// Parse error are handled differently, as the call stack does not matter, only the file location
- catch (simgrid::ParseError& e) {
+ catch (const simgrid::ParseError& e) {
XBT_ERROR("%s", e.what());
XBT_ERROR("Exiting now.");
std::abort();
}
// We manage C++ exception ourselves
- catch (std::exception& e) {
+ catch (const std::exception& e) {
log_exception(xbt_log_priority_critical, "Uncaught exception", e);
show_backtrace(bt);
std::abort();
void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
{
- xbt_log_category_t cat = ev->cat;
+ const xbt_log_category_s* cat = ev->cat;
xbt_assert(ev->priority >= 0, "Negative logging priority naturally forbidden");
xbt_assert(static_cast<size_t>(ev->priority) < sizeof(xbt_log_priority_names)/sizeof(xbt_log_priority_names[0]),
if (XBT_LOG_ISENABLED(log, xbt_log_priority_debug)) {
std::string res;
- xbt_log_category_t cpp = category->parent->firstChild;
+ const xbt_log_category_s* cpp = category->parent->firstChild;
while (cpp) {
res += std::string(" ") + cpp->name;
cpp = cpp->nextSibling;
/* Ok we are good enough to try to get the info we need */
/* First get the start and the end address of the map */
- char* tok = strtok_r(lfields[0], "-", &saveptr);
+ const char* tok = strtok_r(lfields[0], "-", &saveptr);
if (tok == nullptr) {
std::fprintf(stderr,
"Start and end address of the map are not concatenated by a hyphen (-). Recovery impossible.\n");
{
#if HAVE_UNISTD_H
char buffer[2048];
- char* ret = getcwd(buffer, 2048);
+ const char* ret = getcwd(buffer, 2048);
xbt_assert(ret == buffer, "Error during getcwd: %s", strerror(errno));
path_ = std::string(buffer);
#else
std::string simgrid::xbt::Path::get_dir_name()
{
std::string p(path_);
- char *res = dirname(&p[0]);
+ const char* res = dirname(&p[0]);
return std::string(res, strlen(res));
}
std::string simgrid::xbt::Path::get_base_name()
{
std::string p(path_);
- char *res = basename(&p[0]);
+ const char* res = basename(&p[0]);
return std::string(res, strlen(res));
}
delete evt;
}
if (action_queues.find(actor_name_string) != action_queues.end()) {
- std::queue<ReplayAction*>* myqueue = action_queues.at(actor_name_string);
- delete myqueue;
+ delete action_queues.at(actor_name_string);
action_queues.erase(actor_name_string);
}
} else { // Should have got my trace file in argument
int xbt_getpid()
{
- smx_actor_t self = SIMIX_process_self();
+ const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
return self == nullptr ? 0 : self->get_pid();
}