@@ -2599,7 +2599,7 @@ static int get_core_id_from_logical_core_number_solaris(const int** matrix,
2599
2599
/* ---------------------------------------------------------------------------*/
2600
2600
#if defined(OGE_HWLOC) || defined(BINDING_SOLARIS)
2601
2601
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,
2603
2603
int ** list_of_sockets, int * samount, int ** list_of_cores, int * camount,
2604
2604
char ** topo_by_job, int * topo_by_job_length)
2605
2605
{
@@ -2620,12 +2620,13 @@ bool get_linear_automatic_socket_core_list_and_account(const int amount,
2620
2620
int i;
2621
2621
2622
2622
/* 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
+ }
2625
2627
2626
2628
/* 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)) {
2629
2630
2630
2631
/* there are free sockets: use them */
2631
2632
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
2975
2976
/* temporary accounting string -> account on this and
2976
2977
when eventually successful then copy this string back
2977
2978
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
+ }
2980
2983
2981
2984
DPRINTF (" start_at_socket: %d, start_at_core: %d\n " , start_at_socket, start_at_core);
2982
2985
@@ -3007,7 +3010,7 @@ bool get_striding_first_socket_first_core_and_account(const int amount, const in
3007
3010
3008
3011
/* check if we found the socket and core we want to start searching */
3009
3012
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 */
3011
3014
sge_free (&tmp_topo_busy);
3012
3015
DRETURN (false );
3013
3016
}
@@ -3080,15 +3083,13 @@ static bool create_topology_used_per_job(char** accounted_topology, int* account
3080
3083
(*accounted_topology_length) = logical_used_topology_length;
3081
3084
3082
3085
/* 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 = sge_strdup ( nullptr , logical_used_topology );
3087
+ if (*accounted_topology == nullptr ) {
3085
3088
/* out of memory */
3086
3089
return false ;
3087
3090
}
3088
3091
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 */
3092
3093
for (i = 0 ; i < logical_used_topology_length; i++) {
3093
3094
if ((*accounted_topology)[i] == ' c' ) {
3094
3095
(*accounted_topology)[i] = ' C' ;
0 commit comments