Merge branch 'fixprint' of UBB/sort into master

This commit is contained in:
Chris Cromer 2018-11-14 20:18:35 -03:00 committed by Gitea
commit d65c8fbb33
2 changed files with 6 additions and 5 deletions

View File

@ -13,6 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -26,12 +27,12 @@ void count_sort(int *array, int n) {
int j;
int *temp = malloc(sizeof(int) * n);
if (temp == NULL) {
fprintf("Error: Out of heap space!\n");
fprintf(stderr, "Error: Out of heap space!\n");
exit(5);
}
int *count = malloc(sizeof(int) * n);
if (count == NULL) {
fprintf("Error: Out of heap space!\n");
fprintf(stderr, "Error: Out of heap space!\n");
exit(5);
}
memcpy(temp, array, sizeof(int) * n);

View File

@ -83,7 +83,7 @@ int read_buffer(int *variable) {
}
char **check = malloc(sizeof(char**));
if (check == NULL) {
fprintf("Error: Out of heap space!\n");
fprintf(stderr, "Error: Out of heap space!\n");
exit(5);
}
long input = strtol(buffer, check, 10);
@ -203,12 +203,12 @@ int main (int argc, char **argv) {
unordered_array = malloc(sizeof(int) * n);
if (unordered_array == NULL) {
fprintf("Error: Out of heap space!\n");
fprintf(stderr, "Error: Out of heap space!\n");
exit(5);
}
work_array = malloc(sizeof(int) * n);
if (work_array == NULL) {
fprintf("Error: Out of heap space!\n");
fprintf(stderr, "Error: Out of heap space!\n");
exit(5);
}
atexit(cleanup);