@@ -2599,7 +2599,7 @@ static int get_core_id_from_logical_core_number_solaris(const int** matrix,
25992599/* ---------------------------------------------------------------------------*/
26002600#if defined(OGE_HWLOC) || defined(BINDING_SOLARIS)
26012601
2602- bool get_linear_automatic_socket_core_list_and_account (const int amount,
2602+ bool get_linear_automatic_socket_core_list_and_account (const int amount,
26032603 int ** list_of_sockets, int * samount, int ** list_of_cores, int * camount,
26042604 char ** topo_by_job, int * topo_by_job_length)
26052605{
@@ -2620,12 +2620,13 @@ bool get_linear_automatic_socket_core_list_and_account(const int amount,
26202620 int i;
26212621
26222622 /* get the topology which could be used by the job */
2623- tmp_topo_busy = (char *) calloc (logical_used_topology_length, sizeof (char ));
2624- memcpy (tmp_topo_busy, logical_used_topology, logical_used_topology_length*sizeof (char ));
2623+ tmp_topo_busy = sge_strdup (nullptr , logical_used_topology);
2624+ if (tmp_topo_busy == nullptr ) {
2625+ return false ;
2626+ }
26252627
26262628 /* 1. Find all free sockets and try to fit the request on them */
2627- if (get_free_sockets (tmp_topo_busy, logical_used_topology_length, &sockets,
2628- &sockets_size)) {
2629+ if (get_free_sockets (tmp_topo_busy, logical_used_topology_length, &sockets, &sockets_size)) {
26292630
26302631 /* there are free sockets: use them */
26312632 for (i = 0 ; i < sockets_size && used_cores < amount; i++) {
@@ -2975,8 +2976,10 @@ bool get_striding_first_socket_first_core_and_account(const int amount, const in
29752976 /* temporary accounting string -> account on this and
29762977 when eventually successful then copy this string back
29772978 to global topo_busy string */
2978- tmp_topo_busy = (char *) calloc (logical_used_topology_length + 1 , sizeof (char ));
2979- memcpy (tmp_topo_busy, logical_used_topology, logical_used_topology_length*sizeof (char ));
2979+ tmp_topo_busy = sge_strdup (nullptr , logical_used_topology);
2980+ if (tmp_topo_busy == nullptr ) {
2981+ return false ;
2982+ }
29802983
29812984 DPRINTF (" start_at_socket: %d, start_at_core: %d\n " , start_at_socket, start_at_core);
29822985
@@ -3007,7 +3010,7 @@ bool get_striding_first_socket_first_core_and_account(const int amount, const in
30073010
30083011 /* check if we found the socket and core we want to start searching */
30093012 if (sc != start_at_socket || cc != start_at_core) {
3010- /* could 't find the start socket and start core */
3013+ /* couldn 't find the start socket and start core */
30113014 sge_free (&tmp_topo_busy);
30123015 DRETURN (false );
30133016 }
@@ -3080,15 +3083,13 @@ static bool create_topology_used_per_job(char** accounted_topology, int* account
30803083 (*accounted_topology_length) = logical_used_topology_length;
30813084
30823085 /* copy string of current topology in use */
3083- ( *accounted_topology) = ( char *) calloc (logical_used_topology_length+ 1 , sizeof ( char ) );
3084- if (( *accounted_topology) == nullptr ) {
3086+ *accounted_topology = strdup (logical_used_topology );
3087+ if (*accounted_topology == nullptr ) {
30853088 /* out of memory */
30863089 return false ;
30873090 }
30883091
3089- memcpy ((*accounted_topology), logical_used_topology, sizeof (char )*logical_used_topology_length);
3090-
3091- /* revert all accounting from other jobs */
3092+ /* revert all accounting from other jobs */
30923093 for (i = 0 ; i < logical_used_topology_length; i++) {
30933094 if ((*accounted_topology)[i] == ' c' ) {
30943095 (*accounted_topology)[i] = ' C' ;
0 commit comments