MentOS  0.8.0
The Mentoring Operating System
stdlib.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #ifndef __KERNEL__
9 
10 #include "stddef.h"
11 
12 #define EXIT_SUCCESS 0
13 #define EXIT_FAILURE 1
14 
19 size_t malloc_usable_size(void *ptr);
20 
24 void *malloc(unsigned int size);
25 
30 void *calloc(size_t num, size_t size);
31 
40 void *realloc(void *ptr, size_t size);
41 
44 void free(void *ptr);
45 
47 void abort(void);
48 
54 int setenv(const char *name, const char *value, int overwrite);
55 
59 int unsetenv(const char *name);
60 
64 char *getenv(const char *name);
65 
66 #endif
67 
69 #define RAND_MAX ((1U << 31U) - 1U)
70 
73 void srand(unsigned x);
74 
77 unsigned rand(void);
78 
81 float randf(void);
82 
87 int randint(int lb, int ub);
88 
93 unsigned randuint(unsigned lb, unsigned ub);
94 
99 float randfloat(float lb, float ub);
Define basic data types.
float randf(void)
Generates a random floating point number between 0 and 1.
Definition: stdlib.c:123
int unsetenv(const char *name)
Tries to remove the variable from the environment.
Definition: setenv.c:118
int randint(int lb, int ub)
Generates a random integer between lb and ub.
Definition: stdlib.c:128
void * realloc(void *ptr, size_t size)
Reallocates the given area of memory.
Definition: stdlib.c:71
int setenv(const char *name, const char *value, int overwrite)
Tries to adds the variable to the environment.
Definition: setenv.c:57
void srand(unsigned x)
Allows to set the seed of the random value generator.
Definition: stdlib.c:113
float randfloat(float lb, float ub)
Generates a random float between lb and ub.
Definition: stdlib.c:138
void * calloc(size_t num, size_t size)
Allocates a block of memory for an array of num elements.
Definition: stdlib.c:62
void abort(void)
Cause an abnormal program termination with core-dump.
Definition: abort.c:15
size_t malloc_usable_size(void *ptr)
Returns the number of usable bytes in the block pointed to by ptr.
unsigned rand(void)
Generates a random unsigned integer between 0 and RAND_MAX.
Definition: stdlib.c:118
char * getenv(const char *name)
Returns the value of the given variable.
Definition: setenv.c:147
void * malloc(unsigned int size)
Provides dynamically allocated memory.
Definition: stdlib.c:42
unsigned randuint(unsigned lb, unsigned ub)
Generates a random unsigned between lb and ub.
Definition: stdlib.c:133
void free(void *ptr)
Frees dynamically allocated memory.
Definition: stdlib.c:98