PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions
stdlib.h File Reference
#include <stddef.h>
Include dependency graph for stdlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int atoi (const char *)
 Standard functions. More...
 
void qsort (void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *))
 Sorts ARRAY, which contains CNT elements of SIZE bytes each, using COMPARE. More...
 
void * bsearch (const void *key, const void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *))
 Searches ARRAY, which contains CNT elements of SIZE bytes each, for the given KEY. More...
 
void sort (void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *, void *aux), void *aux)
 Nonstandard functions. More...
 
void * binary_search (const void *key, const void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *, void *aux), void *aux)
 lib/stdlib.h More...
 

Function Documentation

◆ atoi()

int atoi ( const char *  s)

Standard functions.

Standard functions.

Definition at line 10 of file stdlib.c.

References ASSERT, isdigit(), isspace(), NULL, and s.

Referenced by expand(), main(), and parse_options().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ binary_search()

void * binary_search ( const void *  key,
const void *  array,
size_t  cnt,
size_t  size,
int(*)(const void *, const void *, void *aux)  compare,
void *  aux 
)

lib/stdlib.h

lib/stdlib.h

Returns a match is found, otherwise a null pointer. If there are multiple matches, returns an arbitrary one of them.

ARRAY must be sorted in order according to COMPARE.

Uses COMPARE to compare elements, passing AUX as auxiliary data. When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B.

Definition at line 185 of file stdlib.c.

References NULL.

Referenced by bsearch().

Here is the caller graph for this function:

◆ bsearch()

void * bsearch ( const void *  key,
const void *  array,
size_t  cnt,
size_t  size,
int(*)(const void *, const void *)  compare 
)

Searches ARRAY, which contains CNT elements of SIZE bytes each, for the given KEY.

Returns a match is found, otherwise a null pointer. If there are multiple matches, returns an arbitrary one of them.

ARRAY must be sorted in order according to COMPARE.

Uses COMPARE to compare elements. When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B.

Definition at line 166 of file stdlib.c.

References binary_search(), and compare_thunk().

Referenced by verify_bsearch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qsort()

void qsort ( void *  array,
size_t  cnt,
size_t  size,
int(*)(const void *, const void *)  compare 
)

Sorts ARRAY, which contains CNT elements of SIZE bytes each, using COMPARE.

When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B. Runs in O(n lg n) time and O(1) space in CNT.

Definition at line 58 of file stdlib.c.

References compare_thunk(), and sort().

Referenced by test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sort()

void sort ( void *  array,
size_t  cnt,
size_t  size,
int(*)(const void *, const void *, void *aux)  compare,
void *  aux 
)

Nonstandard functions.

Nonstandard functions.

When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B. Runs in O(n lg n) time and O(1) space in CNT.

Definition at line 132 of file stdlib.c.

References ASSERT, do_swap(), heapify(), and NULL.

Referenced by qsort().

Here is the call graph for this function:
Here is the caller graph for this function: