X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3a1ea70a418f393ca1677074e928c664022295bd..730305cbe236b9f3d5781ec05d20e730ac6452ff:/src/xbt/dict.cpp diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index af97e2d513..ef3516d5e0 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -1,6 +1,6 @@ /* dict - a generic dictionary, variation over hash table */ -/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -8,13 +8,14 @@ #include "xbt/dict.h" #include "dict_private.h" #include "simgrid/Exception.hpp" -#include "src/xbt_modinter.h" #include "xbt/ex.h" #include "xbt/log.h" #include "xbt/mallocator.h" #include "xbt/str.h" #include "xbt/string.hpp" +#include "xbt/xbt_modinter.h" +#include #include #include @@ -89,8 +90,8 @@ static void xbt_dict_rehash(xbt_dict_t dict) const unsigned oldsize = dict->table_size + 1; unsigned newsize = oldsize * 2; - auto* newtable = static_cast(xbt_realloc((char*)dict->table, newsize * sizeof(xbt_dictelm_t))); - memset(&newtable[oldsize], 0, oldsize * sizeof(xbt_dictelm_t)); /* zero second half */ + auto* newtable = static_cast(xbt_realloc(dict->table, newsize * sizeof(xbt_dictelm_t))); + std::fill(newtable + oldsize, newtable + newsize, nullptr); /* zero second half */ newsize--; dict->table_size = newsize; dict->table = newtable;