vendor/scs/src/util.c in scs-0.4.0 vs vendor/scs/src/util.c in scs-0.4.1
- old
+ new
@@ -3,11 +3,11 @@
#include "glbopts.h"
#include "linsys.h"
#include "scs_matrix.h"
/* return milli-seconds */
-#if (defined NOTIMER)
+#if (defined NO_TIMER)
void SCS(tic)(SCS(timer) * t) {
}
scs_float SCS(tocq)(SCS(timer) * t) {
return NAN;
@@ -82,16 +82,25 @@
memcpy(dest->c, src->c, dest->n * sizeof(scs_float));
}
void SCS(deep_copy_stgs)(ScsSettings *dest, const ScsSettings *src) {
memcpy(dest, src, sizeof(ScsSettings));
+ /* MATLAB does something weird with strdup, so use strcpy instead */
+ char *tmp;
if (src->write_data_filename) {
- dest->write_data_filename = strdup(src->write_data_filename);
+ /* sizeof(char) = 1 */
+ tmp = (char *)scs_malloc(strlen(src->write_data_filename) + 1);
+ strcpy(tmp, src->write_data_filename);
+ dest->write_data_filename = tmp;
} else {
dest->write_data_filename = SCS_NULL;
}
+ /* MATLAB does something weird with strdup, so use strcpy instead */
if (src->log_csv_filename) {
- dest->log_csv_filename = strdup(src->log_csv_filename);
+ /* sizeof(char) = 1 */
+ tmp = (char *)scs_malloc(strlen(src->log_csv_filename) + 1);
+ strcpy(tmp, src->log_csv_filename);
+ dest->log_csv_filename = tmp;
} else {
dest->log_csv_filename = SCS_NULL;
}
}