Explorar o código

sys_alloc(): Show the complete ERRNO of sbrk()

Ioannis Koutras %!s(int64=14) %!d(string=hai) anos
pai
achega
30eb716002
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      sys_alloc.c

+ 3 - 0
sys_alloc.c

@@ -1,5 +1,7 @@
 #include <unistd.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdio.h>
+#include <errno.h>
+#include <string.h>
 #include "posix_lock.h"
 #include "posix_lock.h"
 #include "other.h"
 #include "other.h"
 #include "sys_alloc.h"
 #include "sys_alloc.h"
@@ -17,6 +19,7 @@ void *sys_alloc(heap_t *heap, size_t size) {
 	ptr = sbrk((int) allocation_size);
 	ptr = sbrk((int) allocation_size);
 	if(ptr == (void *) -1) {
 	if(ptr == (void *) -1) {
 		printf("sbrk problem for size of: %d\n", allocation_size);
 		printf("sbrk problem for size of: %d\n", allocation_size);
+		printf( "Error on sbrk: %s\n", strerror( errno ) );
 	}
 	}
 	ptr = (void *) ((char *) ptr + HEADER_SIZE);
 	ptr = (void *) ((char *) ptr + HEADER_SIZE);