44 * is available. Otherwise behaves exactly like calloc. |
45 * is available. Otherwise behaves exactly like calloc. |
45 */ |
46 */ |
46 void *flib_calloc(size_t count, size_t elementsize); |
47 void *flib_calloc(size_t count, size_t elementsize); |
47 |
48 |
48 /** |
49 /** |
|
50 * Simple realloc wrapper that automatically logs an error if no memory |
|
51 * is available. Otherwise behaves exactly like realloc. |
|
52 */ |
|
53 void *flib_realloc(void *ptr, size_t size); |
|
54 |
|
55 /** |
49 * Replace all non-alphanumeric and non-ascii bytes with escape |
56 * Replace all non-alphanumeric and non-ascii bytes with escape |
50 * sequences in the form %XX. Does not modify the original string, |
57 * sequences in the form %XX. Does not modify the original string, |
51 * but returns a newly allocated one that must be free()d. Returns |
58 * but returns a newly allocated one that must be free()d. Returns |
52 * null on failure or if null was passed as argument. |
59 * null on failure or if null was passed as argument. |
53 * |
60 * |
54 * This should work fine with all ASCII-based charsets including UTF-8. |
61 * This should work fine with all ASCII-based charsets including UTF-8. |
55 */ |
62 */ |
56 char *flib_urlencode(const char *str); |
63 char *flib_urlencode(const char *str); |
57 |
64 |
58 /** |
65 /** |
|
66 * Replace some bytes with escape sequences in the form %XX. |
|
67 * Does not modify the original string, but returns a newly allocated |
|
68 * one that must be free()d. |
|
69 * |
|
70 * All bytes for which the predicate function returns true are escaped. |
|
71 * |
|
72 * Returns null on failure or if null was passed as argument. |
|
73 */ |
|
74 char *flib_urlencode_pred(const char *str, bool (*needsEscaping)(char c)); |
|
75 |
|
76 /** |
59 * Replace escape sequences of the form %XX with their byte values. |
77 * Replace escape sequences of the form %XX with their byte values. |
60 * Does not modify the original string, but returns a newly allocated |
78 * Does not modify the original string, but returns a newly allocated |
61 * one that must be free()d. Returns null on failure or if null was |
79 * one that must be free()d. Returns null on failure or if null was |
62 * passed as argument. |
80 * passed as argument. |
63 */ |
81 */ |