commit
5fc3ad0b47
8
.gitea/workflows/test.yml
Normal file
8
.gitea/workflows/test.yml
Normal file
@ -0,0 +1,8 @@
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test1:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
context: .
|
||||
build: Dockerfile
|
||||
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk add gcc
|
||||
RUN mkdir /app
|
||||
|
||||
COPY *.c /app/
|
||||
COPY test.sh /
|
||||
RUN chmod +x "test.sh"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT ["/test.sh"]
|
||||
49
f.c
Normal file
49
f.c
Normal file
@ -0,0 +1,49 @@
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
size_t malloc_counter;
|
||||
size_t free_counter;
|
||||
|
||||
void * TEST_MALLOC(size_t size)
|
||||
{
|
||||
printf("malloc'ed %lu\n", size);
|
||||
|
||||
malloc_counter += size;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void TEST_FREE(void *p)
|
||||
{
|
||||
size_t s = malloc_usable_size(p) - 8;
|
||||
printf("freed %lu\n", s);
|
||||
|
||||
free_counter += s;
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
#define malloc TEST_MALLOC
|
||||
#define free TEST_FREE
|
||||
int f(void)
|
||||
{
|
||||
free(malloc(16));
|
||||
free(malloc(32));
|
||||
free(malloc(48));
|
||||
free(malloc(64));
|
||||
free(malloc(96));
|
||||
malloc(128);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
int main(void)
|
||||
{
|
||||
malloc_counter = free_counter = 0;
|
||||
(void) f();
|
||||
|
||||
printf("malloc: %lu, free: %lu\n", malloc_counter, free_counter);
|
||||
|
||||
return malloc_counter != free_counter;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user