Malloc Markingsheet
Malloc Markingsheet
search... trevor
(https://profile.intra.42.fr)
Introduction
Please respect the following rules:
depends on it.
- Identify with the person (or the group) graded the eventual
- You must consider that there might be some difference in how your
Guidelines
You MUST run the requested tests.
of this project:
mechanism.
Attachments
subject (https://cdn.intra.42.fr/pdf/pdf/5644/ft_malloc.en.pdf)
Preview!!!
Preliminaries
Preliminary tests
Yes No
Library compilation
$> make re
...
$> ls -l libft_malloc.so
The Makefile does use HOSTTYPE to define the name of the library
Yes No
Functions export
Check with nm that the library does export the functions
$> nm libft_malloc.so
0000000000000000 T _free
0000000000000000 T _malloc
0000000000000000 T _realloc
0000000000000000 T_show_alloc_mem
U _mmap
U _munmap
U _getpagesize
U _write
U dyld_stub_binder
$>
change from one library to the next, same as the order of the
lines).
Yes No
Feature's testing
Start by creating a script that will only modify the environment variables while you run a test program. It will be named run.sh, and be
executable: $> cat run.sh #!/bin/sh export DYLD_LIBRARY_PATH=. export DYLD_INSERT_LIBRARIES="libft_malloc.so" export
DYLD_FORCE_FLAT_NAMESPACE=1 $@
Malloc test
We are first going to make a first test program that does not use
#include
int main()
i = 0;
{
i++;
return (0);
0 page faults
0 swaps
0 messages sent
0 messages received
0 signals received
$>
The system will only really allocate the memory of a page if you
#include
int main()
int i;
char *addr;
i = 0;
addr = (char*)malloc(1024);
addr[0] = 42;
i++;
}
return (0);
0 page faults
0 swaps
0 messages sent
0 messages received
0 signals received
$>
value of getpagesize(3)
0 page faults
0 swaps
0 messages sent
0 messages received
0 signals received
0 page faults
0 swaps
0 messages sent
0 messages received
0 signals received
$>
We notice in this example that this malloc has used 1024 pages
Count the number of pages used and adjust the grade as such:
- between 255 and 272 pages, malloc works and the overhead
is fine: 5
Check inside the source code that the pre -allocated zones for
the maximum size for this type of zone. Check also that the
Yes No
Tests of free
#include
int main()
int i;
char *addr;
i = 0;
addr = (char*)malloc(1024);
addr[0] = 42;
free(addr);
i++;
return (0);
Yes No
Realloc test
#include
#include
write(1, s, strlen(s));
int main()
char *addr1;
char *addr3;
addr1 = (char*)malloc(16*M);
strcpy(addr1, "Bonjour\n");
print(addr1);
addr3[127*M] = 42;
print(addr3);
return (0);
Bonjour
Bonjour
$>
Yes No
Realloc test++
int main()
char *addr1;
char *addr2;
char *addr3;
addr1 = (char*)malloc(16*M);
strcpy(addr1, "Bonjour\n");
print(addr1);
addr2 = (char*)malloc(16*M);
return (0);
Yes No
#include
#include
#include
write(1, s, strlen(s));
int main()
char *addr;
addr = malloc(16);
free(NULL);
print("Bonjour\n");
}
Bonjour
Yes No
Show_alloc_mem test
#include
int main()
malloc(1024);
malloc(1024 * 32);
malloc(1024 * 1024);
show_alloc_mem();
return (0);
$> ./test5
Yes No
Bonus
Competitive access
The project manages the competitive access of the threads with
Additional bonuses
Bonus example:
- ...
du correcteur).
Ratings
Don ’t forget to check the flag corresponding to the defense
Ok Outstanding project
Conclusion
Leave a comment on this evaluation
General term of use of the site Privacy policy Legal notices Declaration on the use of cookies Terms of use for video surveillance R