61 + m1 = malloc(sizea * sizeb * sizeof(int)); 62 + m2 = malloc(sizeb * sizec * sizeof(int)); 63 + r = malloc(sizea * sizec * sizeof(int)); 64 + if (!m1 || !m2 || !r) { 65 + fprintf(stderr, "WARNING: Thread %3d could not allocate %lld Mbytes\n", 66 + th_arg->t_thnum, mem_size); 67 + th_arg->t_return = -1; 68 + pthread_exit(NULL); 69 + }
You can leak m2 and m1 ir f fails to allocate. I'd use 'goto out;' and place out: on the first of the three free(); calls below.
« Back to merge proposal
61 + m1 = malloc(sizea * sizeb * sizeof(int));
62 + m2 = malloc(sizeb * sizec * sizeof(int));
63 + r = malloc(sizea * sizec * sizeof(int));
64 + if (!m1 || !m2 || !r) {
65 + fprintf(stderr, "WARNING: Thread %3d could not allocate %lld Mbytes\n",
66 + th_arg->t_thnum, mem_size);
67 + th_arg->t_return = -1;
68 + pthread_exit(NULL);
69 + }
You can leak m2 and m1 ir f fails to allocate. I'd use 'goto out;' and place out: on the first of the three free(); calls below.