mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
start moving malloc and friends in
This commit is contained in:
1
userland/glibc/README.adoc
Normal file
1
userland/glibc/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
This directory contains glibc extensions to POSIX / ANSI C.
|
||||
24
userland/glibc/brk.c
Normal file
24
userland/glibc/brk.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#brk */
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
void *b = sbrk(0);
|
||||
int *p = (int *)b;
|
||||
|
||||
/* Move it 2 ints forward */
|
||||
brk(p + 2);
|
||||
|
||||
/* Use the ints. */
|
||||
*p = 1;
|
||||
*(p + 1) = 2;
|
||||
assert(*p == 1);
|
||||
assert(*(p + 1) == 2);
|
||||
|
||||
/* Deallocate back. */
|
||||
brk(b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
1
userland/glibc/build
Symbolic link
1
userland/glibc/build
Symbolic link
@@ -0,0 +1 @@
|
||||
../build
|
||||
1
userland/glibc/test
Symbolic link
1
userland/glibc/test
Symbolic link
@@ -0,0 +1 @@
|
||||
../test
|
||||
Reference in New Issue
Block a user