initial commit
Some checks failed
/ test1 (push) Failing after -1s

This commit is contained in:
ІО-23 Шмуляр Олег 2026-03-18 17:16:32 +02:00
commit 5fc3ad0b47
4 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,8 @@
on: [push]
jobs:
test1:
runs-on: ubuntu-latest
container:
context: .
build: Dockerfile

12
Dockerfile Normal file
View 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
View 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;
}

5
test.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
gcc /app/f.c -o /app/f
./f