DEV 3.2 ; TP01

This commit is contained in:
2022-10-05 11:07:41 +02:00
parent 8f86f3798f
commit 9bca200351
30 changed files with 383 additions and 1 deletions

15
Fun/NewMalloc/newmem.c Normal file
View File

@@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "newmem.h"
void* newmalloc(size_t size) {
void* start = sbrk(0);
void* finish = sbrk(size);
printf("%d\n", finish);
if (start == finish) return NULL;
return finish;
}

6
Fun/NewMalloc/newmem.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef NEWMEM
#define NEWMEM
void* newmalloc(size_t size);
#endif

9
Fun/NewMalloc/test.c Normal file
View File

@@ -0,0 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "newmem.h"
int main(void) {
char* t = (char*)newmalloc(15);
printf("%d", t != NULL);
}