Memory management.
More...
|
void | gf_free (void *ptr) |
|
void * | gf_malloc (size_t size) |
|
void * | gf_calloc (size_t num, size_t size_of) |
|
char * | gf_strdup (const char *str) |
|
void * | gf_realloc (void *ptr, size_t size) |
|
GF_Err | gf_dynstrcat (char **str, const char *to_append, const char *sep) |
| dynamic string concatenation More...
|
|
Bool | gf_parse_lfrac (const char *str, GF_Fraction64 *frac) |
| fraction parsing More...
|
|
Bool | gf_parse_frac (const char *str, GF_Fraction *frac) |
| fraction parsing More...
|
|
Bool | gf_strnistr (const char *text, const char *subtext, u32 subtext_len) |
| search string without case More...
|
|
u64 | gf_timestamp_rescale (u64 value, u64 timescale, u64 new_timescale) |
| safe timestamp rescale More...
|
|
s64 | gf_timestamp_rescale_signed (s64 value, u64 timescale, u64 new_timescale) |
| safe signed timestamp rescale More...
|
|
Bool | gf_timestamp_less (u64 value1, u64 timescale1, u64 value2, u64 timescale2) |
| compare timestamps More...
|
|
Bool | gf_timestamp_less_or_equal (u64 value1, u64 timescale1, u64 value2, u64 timescale2) |
| compare timestamps More...
|
|
Bool | gf_timestamp_greater (u64 value1, u64 timescale1, u64 value2, u64 timescale2) |
| compare timestamps More...
|
|
Bool | gf_timestamp_greater_or_equal (u64 value1, u64 timescale1, u64 value2, u64 timescale2) |
| compare timestamps More...
|
|
Bool | gf_timestamp_equal (u64 value1, u64 timescale1, u64 value2, u64 timescale2) |
| compare timestamps More...
|
|
GPAC can use its own memory tracker, depending on compilation option. It is recommended to use only the functions defined in this section to allocate and free memory whenever developing within the GPAC library.
- Warning
- these functions shall only be used after initializing the library using gf_sys_init
◆ GF_SAFEALLOC
#define GF_SAFEALLOC |
( |
|
__ptr, |
|
|
|
__struct |
|
) |
| |
Macro allocating memory and zero-ing it
◆ GF_SAFE_ALLOC_N
#define GF_SAFE_ALLOC_N |
( |
|
__ptr, |
|
|
|
__n, |
|
|
|
__struct |
|
) |
| |
Macro allocating memory for n structures and zero-ing it
◆ gf_free()
void gf_free |
( |
void * |
ptr | ) |
|
free memory allocated with gpac
- Parameters
-
◆ gf_malloc()
void* gf_malloc |
( |
size_t |
size | ) |
|
allocates memory, shall be freed using gf_free
- Parameters
-
- Returns
- address of allocated block
◆ gf_calloc()
void* gf_calloc |
( |
size_t |
num, |
|
|
size_t |
size_of |
|
) |
| |
allocates memory array, shall be freed using gf_free
- Parameters
-
num | same as calloc() |
size_of | same as calloc() |
- Returns
- address of allocated block
◆ gf_strdup()
char* gf_strdup |
( |
const char * |
str | ) |
|
duplicates string, shall be freed using gf_free
- Parameters
-
- Returns
- duplicated string
◆ gf_realloc()
void* gf_realloc |
( |
void * |
ptr, |
|
|
size_t |
size |
|
) |
| |
reallocates memory, shall be freed using gf_free
- Parameters
-
ptr | same as realloc() |
size | same as realloc() |
- Returns
- address of reallocated block
◆ gf_dynstrcat()
GF_Err gf_dynstrcat |
( |
char ** |
str, |
|
|
const char * |
to_append, |
|
|
const char * |
sep |
|
) |
| |
Dynamic concatenation of string with optional separator
- Parameters
-
str | pointer to destination string pointer |
to_append | string to append |
sep | optional separator string to insert before concatenation. If set and initial string is NULL, will not be appended |
- Returns
- error code
◆ gf_parse_lfrac()
Parse a 64 bit fraction from string
- Parameters
-
str | string to parse |
frac | fraction to fill |
- Returns
- GF_TRUE if success, GF_FALSE otherwise ( fraction being set to {0,0} )
◆ gf_parse_frac()
Parse a 32 bit fraction from string
- Parameters
-
str | string to parse |
frac | fraction to fill |
- Returns
- GF_TRUE if success, GF_FALSE otherwise ( fraction being set to {0,0} )
◆ gf_strnistr()
Bool gf_strnistr |
( |
const char * |
text, |
|
|
const char * |
subtext, |
|
|
u32 |
subtext_len |
|
) |
| |
Search a aubstring in a string witout checking for case
- Parameters
-
text | text to search |
subtext | string to find |
subtext_len | length of string to find |
- Returns
- GF_TRUE if success, GF_FALSE otherwise
◆ gf_timestamp_rescale()
u64 gf_timestamp_rescale |
( |
u64 |
value, |
|
|
u64 |
timescale, |
|
|
u64 |
new_timescale |
|
) |
| |
Rescale a 64 bit timestamp value to new timescale, i.e. performs value * new_timescale / timescale
- Parameters
-
value | value to rescale. A value of -1 means no timestamp defined and is returned unmodified |
timescale | timescale of value. Assumed to be less than 0xFFFFFFFF |
new_timescale | new timescale? Assumed to be less than 0xFFFFFFFF |
- Returns
- new value
◆ gf_timestamp_rescale_signed()
s64 gf_timestamp_rescale_signed |
( |
s64 |
value, |
|
|
u64 |
timescale, |
|
|
u64 |
new_timescale |
|
) |
| |
Rescale a 64 bit timestamp value to new timescale, i.e. performs value * new_timescale / timescale
- Parameters
-
value | value to rescale |
timescale | timescale of value. Assumed to be less than 0xFFFFFFFF |
new_timescale | new timescale. Assumed to be less than 0xFFFFFFFF |
- Returns
- new value
◆ gf_timestamp_less()
Bool gf_timestamp_less |
( |
u64 |
value1, |
|
|
u64 |
timescale1, |
|
|
u64 |
value2, |
|
|
u64 |
timescale2 |
|
) |
| |
Compares two timestamps
- Parameters
-
value1 | value to rescale |
timescale1 | timescale of value. Assumed to be less than 0xFFFFFFFF |
value2 | value to rescale |
timescale2 | timescale of value. Assumed to be less than 0xFFFFFFFF |
- Returns
- GF_TRUE if (value1 / timescale1) is stricly less than (value2 / timescale2)
◆ gf_timestamp_less_or_equal()
Bool gf_timestamp_less_or_equal |
( |
u64 |
value1, |
|
|
u64 |
timescale1, |
|
|
u64 |
value2, |
|
|
u64 |
timescale2 |
|
) |
| |
Compares two timestamps
- Parameters
-
value1 | value to rescale |
timescale1 | timescale of value. Assumed to be less than 0xFFFFFFFF |
value2 | value to rescale |
timescale2 | timescale of value. Assumed to be less than 0xFFFFFFFF |
- Returns
- GF_TRUE if (value1 / timescale1) is stricly less than or equal to (value2 / timescale2)
◆ gf_timestamp_greater()
Bool gf_timestamp_greater |
( |
u64 |
value1, |
|
|
u64 |
timescale1, |
|
|
u64 |
value2, |
|
|
u64 |
timescale2 |
|
) |
| |
Compares two timestamps
- Parameters
-
value1 | value to rescale |
timescale1 | timescale of value. Assumed to be less than 0xFFFFFFFF |
value2 | value to rescale |
timescale2 | timescale of value. Assumed to be less than 0xFFFFFFFF |
- Returns
- GF_TRUE if (value1 / timescale1) is stricly greater than (value2 / timescale2)
◆ gf_timestamp_greater_or_equal()
Bool gf_timestamp_greater_or_equal |
( |
u64 |
value1, |
|
|
u64 |
timescale1, |
|
|
u64 |
value2, |
|
|
u64 |
timescale2 |
|
) |
| |
Compares two timestamps
- Parameters
-
value1 | value to rescale |
timescale1 | timescale of value. Assumed to be less than 0xFFFFFFFF |
value2 | value to rescale |
timescale2 | timescale of value. Assumed to be less than 0xFFFFFFFF |
- Returns
- GF_TRUE if (value1 / timescale1) is stricly greater than or equal to (value2 / timescale2)
◆ gf_timestamp_equal()
Bool gf_timestamp_equal |
( |
u64 |
value1, |
|
|
u64 |
timescale1, |
|
|
u64 |
value2, |
|
|
u64 |
timescale2 |
|
) |
| |
Compares two timestamps
- Parameters
-
value1 | value to rescale |
timescale1 | timescale of value. Assumed to be less than 0xFFFFFFFF |
value2 | value to rescale |
timescale2 | timescale of value. Assumed to be less than 0xFFFFFFFF |
- Returns
- GF_TRUE if (value1 / timescale1) is equal to (value2 / timescale2)