Ustr - 1.0.4 reference documentation -- functions (301) |
Creating read-only Ustr functions |
|
Function: USTR()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Pointer to Ustr data Type[1]: void * |
| Explanation: |
This macro function is normally used with the empty string "". |
| Note: |
There is basically just a simple cast behind the macro. |
|
Function: USTRP()
Returns: Ustrp string Type: struct Ustrp * |
| Parameter[1]: Pointer to Ustrp data Type[1]: void * |
| Explanation: |
This macro function is normally used with the empty string "". |
| Note: |
There is basically just a simple cast behind the macro. |
|
Function: USTR1()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Data for Ustr string Type[2]: const char[] |
| Explanation: |
This macro function simplifies the creation of read-only Ustr string's. And is normally used like... USTR1(\x4, "abcd") ...it is worth pointing out that running with debugging turned on (USTR_CONF_USE_ASSERT) will complain if the length isn't encoded correctly, as in... USTR1(\x3, "abcd") ...here ustr_assert_valid() will fail, which is called before most functions do anything in debugging mode. Note also that extra debugging (USTR_CONF_USE_EOS_MARK) will still catch cases like... USTR1(\x3, "abc\0d") ...at least using debugging is esp. important if you are putting UTF-8 characters into the strings. |
| Note: |
Having ustr_ro() return true means that the Ustr cannot be written to without be reallocated into allocation space ... not that ustr_add() etc. will fail. There is now USTR1_CHK() which performs a compile time check so you can never have an invalid ustr. |
|
Function: USTR2()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded 2nd byte of number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Encoded 1st byte of number of the length of Ustr string Type[2]: symbol |
| Parameter[3]: Data for Ustr string Type[3]: const char[] |
| Explanation: |
This function works in the same way as USTR1() but takes two length bytes, so the read-only string can be upto 65,535 (2**16 - 1) bytes in length. |
|
Function: USTR4()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded 4th byte of number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Encoded 3rd byte of number of the length of Ustr string Type[2]: symbol |
| Parameter[3]: Encoded 2nd byte of number of the length of Ustr string Type[3]: symbol |
| Parameter[4]: Encoded 1st byte of number of the length of Ustr string Type[4]: symbol |
| Parameter[5]: Data for Ustr string Type[5]: const char[] |
| Explanation: |
This function works in the same way as USTR1() but takes four length bytes, so the read-only string can be upto 2**32 - 1 bytes in length. |
|
Function: USTR1_CHK()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Data for Ustr string Type[2]: const char[] |
| Explanation: |
This function works in the same way as USTR1() but it does a check against the length of (Parameter[2]) using sizeof() - 1. |
| Note: |
If the check fails the returned Ustr * will be "", so you can check ustr_len() to see if you screwed something up. |
|
Function: USTR2_CHK()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded 2nd byte of number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Encoded 1st byte of number of the length of Ustr string Type[2]: symbol |
| Parameter[3]: Data for Ustr string Type[3]: const char[] |
| Explanation: |
This function works in the same way as USTR2() but it does a check against the length of (Parameter[2]) using sizeof() - 1. |
| Note: |
If the check fails the returned Ustr * will be "". |
|
Function: USTR4_CHK()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded 4th byte of number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Encoded 3rd byte of number of the length of Ustr string Type[2]: symbol |
| Parameter[3]: Encoded 2nd byte of number of the length of Ustr string Type[3]: symbol |
| Parameter[4]: Encoded 1st byte of number of the length of Ustr string Type[4]: symbol |
| Parameter[5]: Data for Ustr string Type[5]: const char[] |
| Explanation: |
This function works in the same way as USTR4() but it does a check against the length of (Parameter[2]) using sizeof() - 1. |
| Note: |
If the check fails the returned Ustr * will be "". |
|
Function: USTRP1()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Data for Ustr string Type[2]: const char[] |
| Explanation: |
This function works like USTR1(), but returns a Ustrp instead. |
|
Function: USTRP2()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded 2nd byte of number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Encoded 1st byte of number of the length of Ustr string Type[2]: symbol |
| Parameter[3]: Data for Ustr string Type[3]: const char[] |
| Explanation: |
This function works like USTR4(), but returns a Ustrp instead. |
|
Function: USTRP4()
Returns: Ustrp string Type: struct Ustrp * |
| Parameter[1]: Encoded 4th byte of number of the length of Ustrp string Type[1]: symbol |
| Parameter[2]: Encoded 3rd byte of number of the length of Ustrp string Type[2]: symbol |
| Parameter[3]: Encoded 2nd byte of number of the length of Ustrp string Type[3]: symbol |
| Parameter[4]: Encoded 1st byte of number of the length of Ustrp string Type[4]: symbol |
| Parameter[5]: Data for Ustr string Type[5]: const char[] |
| Explanation: |
This function works like USTR2(), but returns a Ustrp instead. |
|
Function: USTRP1_CHK()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Data for Ustr string Type[2]: const char[] |
| Explanation: |
This function works like USTR1_CHK(), but returns a Ustrp instead. |
|
Function: USTRP2_CHK()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Encoded 2nd byte of number of the length of Ustr string Type[1]: symbol |
| Parameter[2]: Encoded 1st byte of number of the length of Ustr string Type[2]: symbol |
| Parameter[3]: Data for Ustr string Type[3]: const char[] |
| Explanation: |
This function works like USTR4_CHK(), but returns a Ustrp instead. |
|
Function: USTRP4_CHK()
Returns: Ustrp string Type: struct Ustrp * |
| Parameter[1]: Encoded 4th byte of number of the length of Ustrp string Type[1]: symbol |
| Parameter[2]: Encoded 3rd byte of number of the length of Ustrp string Type[2]: symbol |
| Parameter[3]: Encoded 2nd byte of number of the length of Ustrp string Type[3]: symbol |
| Parameter[4]: Encoded 1st byte of number of the length of Ustrp string Type[4]: symbol |
| Parameter[5]: Data for Ustr string Type[5]: const char[] |
| Explanation: |
This function works like USTR2_CHK(), but returns a Ustrp instead. |
Creating fixed Ustr functions |
|
Function: USTR_SIZE_FIXED()
Returns: Size of area of memory Type: size_t |
| Parameter[1]: Size of area of memory Type[1]: size_t |
| Explanation: |
This macro function is replaced by a static conversion from the max length desired (Parameter[1]) to the storage size needed. In other words it works out what ustr_size_overhead() will be, and adds that value. |
| Note: |
This is useful is you want a small fixed size allocation, as you can declare it like so: char buf[USTR_SIZE_FIXED(4)]; ...to give you exactly 4 bytes as a maximum, this is esp. useful if you want a limited (ustr_limited() == USTR_TRUE) Ustr string. |
|
Function: ustr_init_fixed()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Pointer to area of memory to use as a Ustr string Type[1]: void * |
| Parameter[2]: Size of area of memory Type[2]: size_t |
| Parameter[3]: Whether the fixed size Ustr should be limited Type[3]: int |
| Parameter[4]: The initial length of the Ustr Type[4]: size_t |
| Explanation: |
This creates a new Ustr string, which is "fixed". This means the Ustr storage is managed outside of the ustr_* API, it is often used for stack allocated strings. As you add data to the Ustr past the size allowed via. the fixed storge the Ustr will automatically be converted into an allocated Ustr. So if this is possible you should always call ustr_free(), as this does nothing if given a fixed size Ustr. |
| Note: |
For simplicity you probably want to use USTR_SC_INIT_AUTO() or USTR_SC_INIT_AUTO() when possible. |
|
Function: USTR_SC_INIT_AUTO()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Area of memory to use as a Ustr string Type[1]: char[] |
| Parameter[2]: Whether the fixed size Ustr should be limited Type[2]: int |
| Parameter[3]: The initial length of the Ustr Type[3]: size_t |
| Explanation: |
This calls ustr_init_fixed() with sizeof() the area of memory (Parameter[1]) as the second argument. |
| Note: |
This does mean that the first argument must be the correct size, as far as sizeof() is concerned, as in... char buf_sz[1024]; Ustr *s1 = USTR_SC_INIT_AUTO(buf_sz, USTR_FALSE, 0); ...so passing pointers to memory from malloc() will probably just return NULL. |
|
Function: USTR_SC_INIT_AUTO_OSTR()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Area of memory to use as a Ustr string Type[1]: char[] |
| Parameter[2]: Whether the fixed size Ustr should be limited Type[2]: int |
| Parameter[3]: The initial string in the buffer, as a constant string Type[3]: size_t |
| Explanation: |
This calls ustr_init_fixed() with sizeof() the area of memory (Parameter[1]) as the second argument, given as an "object string". |
| Note: |
This does mean that the first argument must be the correct size, as far as sizeof() is concerned, as in... char buf_sz[1024] = USTR_BEG_FIXED2 "abcd"; Ustr *s1 = USTR_SC_INIT_AUTO_OSTR(buf_sz, USTR_FALSE, "abcd"); ...so passing pointers to memory from malloc() will probably just return NULL. |
Debugging functions |
|
Function: ustr_assert_valid()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a Ustr string Type[1]: Ustr * |
| Explanation: |
This function asserts a few internal consistency checks, and can help point out when a Ustr is invalid. |
| Note: |
This calls ustr_assert_ret() so that when USTR_DEBUG if off the checks are still performed and the result is returned. |
|
Function: ustr_assert_valid_subustr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a Ustr string Type[1]: Ustr * |
| Parameter[2]: Position in the Ustr Type[2]: size_t |
| Parameter[3]: Length to delete from the Ustr Type[3]: size_t |
| Explanation: |
This function calls ustr_assert_valid() and also checks that the position and length are within the Ustr. If they aren't valid it returns 0, if they are valid it returns ustr_len(). |
|
Function: USTR_CNTL_MALLOC_CHECK_BEG()
Returns: Success or failure Type: int |
| Parameter[1]: Condition for begin malloc checking or not Type[1]: int |
| Explanation: |
This function begins malloc checking, meaning all ustr allocations will go through the malloc check routines, but it fails if the condition check (Parameter[1]) fails. |
| Note: |
Turning malloc checking on after one or more allocations has happened will lead to false failures unless you really known what you are doing. You can automatically turn malloc checking on by giving the USTR_CNTL_MC environment variable the value of "1", "yes" or "on". |
|
Function: USTR_CNTL_MALLOC_CHECK_LVL()
Returns: Level of current malloc check Type: int |
| Parameter[1]: Nothing Type[1]: void |
| Explanation: |
This function returns the current "level" of the malloc check, with 0 indicating that malloc check isn't enabled. The level goes up by one whenever USTR_CNTL_MALLOC_CHECK_BEG() or USTR_CNTL_MALLOC_CHECK_ADD() returns success, and goes down by one whenever USTR_CNTL_MALLOC_CHECK_DEL() or USTR_CNTL_MALLOC_CHECK_END() returns success. |
|
Function: USTR_CNTL_MALLOC_CHECK_MEM()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer returned from malloc check Type[1]: void * |
| Explanation: |
This function asserts that the pointer (Parameter[1]) was allocated from malloc checking. |
| Note: |
Unless you are doing something special, or using a builtin Ustr_pool it is very likely you want to just call USTR_CNTL_MALLOC_CHECK_MEM_USTR(). |
|
Function: USTR_CNTL_MALLOC_CHECK_MEM_SZ()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer returned from malloc check Type[1]: void * |
| Parameter[2]: Length of allocated memory Type[2]: size_t |
| Explanation: |
This function asserts that the pointer (Parameter[1]) was allocated from malloc checking, and has the specified size (Parameter[2]). |
| Note: |
Unless you are doing something special, or using a builtin Ustr_pool it is very likely you want to just call USTR_CNTL_MALLOC_CHECK_MEM_USTR(). |
|
Function: USTR_CNTL_MALLOC_CHECK_MEM_MINSZ()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer returned from malloc check Type[1]: void * |
| Parameter[2]: Length of allocated memory Type[2]: size_t |
| Explanation: |
This function asserts that the pointer (Parameter[1]) was allocated from malloc checking, and has at least the specified size (Parameter[2]). |
| Note: |
Unless you are doing something special, or using a builtin Ustr_pool it is very likely you want to just call USTR_CNTL_MALLOC_CHECK_MEM_USTR(). |
|
Function: USTR_CNTL_MALLOC_CHECK_MEM_USTR()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a Ustr string Type[1]: Ustr * |
| Explanation: |
This function asserts that the pointer (Parameter[1]) is a Ustr allocated from malloc checking, if the Ustr is allocated (if not it returns TRUE). |
| Note: |
Because of the layering between the Ustr code and the pool code, if you allocate an implicity sized Ustrp from a pool and then delete some data from it (which fails) the Ustr layer will think it has an implicit less than the actual size so this function will fail. This is what USTR_CNTL_MALLOC_CHECK_MEM_USTRP() is for. |
|
Function: USTR_CNTL_MALLOC_CHECK_MEM_USTRP()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a Ustrp string Type[1]: Ustrp * |
| Explanation: |
This function asserts that the pointer (Parameter[1]) is a Ustr allocated from a builtin pool using malloc checking, if the Ustr is allocated (if not it returns TRUE). |
|
Function: USTR_CNTL_MALLOC_CHECK_END()
Returns: Success or failure Type: int |
| Parameter[1]: Nothing Type[1]: void |
| Explanation: |
This macro will cleanup any memory used by malloc check, and assert that no memory is left allocated. |
| Note: |
If any memory is left allocated, each one found is output to stderr with the file/line/function of the level it was allocated from. |
|
Function: USTR_CNTL_MALLOC_CHECK_ADD()
Returns: Success or failure Type: int |
| Parameter[1]: Condition to begin malloc checking or not Type[1]: int |
| Explanation: |
This function works like USTR_CNTL_MALLOC_CHECK_END() but it fails if the condition check (Parameter[1]) fails, or if USTR_CNTL_MALLOC_CHECK_LVL() is zero. |
|
Function: USTR_CNTL_MALLOC_CHECK_DEL()
Returns: Success or failure Type: int |
| Parameter[1]: Condition to end malloc checking or not Type[1]: int |
| Explanation: |
This function works like USTR_CNTL_MALLOC_CHECK_END() but it fails if the condition check (Parameter[1]) fails, or if USTR_CNTL_MALLOC_CHECK_LVL() is one. |
| Note: |
The condition (Parameter[1]) to this macro should almost certainly be the return value from USTR_CNTL_MALLOC_CHECK_ADD(). |
Creating allocated Ustr functions |
|
Function: ustr_init_size()
Returns: Size that needs to be allocated Type: size_t |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: Length of data in the Ustr Type[4]: size_t |
| Explanation: |
This function finds out the exact size of memory needed to store the specified Ustr of the given configuration. |
|
Function: ustr_init_alloc()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Pointer to area of memory to use as a Ustr string Type[1]: void * |
| Parameter[2]: Size of area of memory Type[2]: size_t |
| Parameter[3]: Whether Ustr should store the size Type[3]: size_t |
| Parameter[4]: Number of bytes to use for references Type[4]: size_t |
| Parameter[5]: Whether the Ustr should use exact allocations Type[5]: int |
| Parameter[6]: Whether the Ustr should have the "enomem" flag set Type[6]: int |
| Parameter[7]: The initial length of the Ustr Type[7]: size_t |
| Explanation: |
This creates a new Ustr string, you should have allocated the data via. USTR_CONF_MALLOC() or bad things will happen if the Ustr string is ever free'd or reallocated. |
|
Function: ustr_dupx_empty()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocation flag Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Explanation: |
This function creates an empty Ustr, owned by you, that is allocated from system memory, or it returns NULL. The size is the desired allocation size for the entire Ustr, including overhead for metadata. This value will be rounded up, if it's too small, so passing 1 as the size means you want a stored size but to allocate the smallest amount of memory possible. The exact memory allocation flag says if the Ustr should round allocations up to the nearest half power of two or should be no more than needed. The ENOMEM memory error flag sets the iniital state of the user visible flag for memory allocation errors. Eg. ustr_enomem(), ustr_setf_enomem_clr() and ustr_setf_enomem_err() |
| Note: |
The reference byte count can only be one of the following values: 0, 1, 2 or 4, or 8 (on environments with a 64bit size_t). It can be useful to ensure that the Ustr is in system memory, so that you can add things to it and check for errors with ustr_enomem(). If you chose to store the allocated size in the Ustr then the number of bytes allocated for the reference count will be a minimum of 2. |
|
Function: ustr_dup_empty()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Nothing Type[1]: void |
| Explanation: |
This function is the same as calling ustr_dupx_empty() with the current set of default options. |
|
Function: ustr_dupx_undef()
Returns: Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Length of new undefined data Type[5]: size_t |
| Explanation: |
This function works like you called ustr_dupx_empty() and then ustr_add_undef(). |
|
Function: ustr_dup_undef()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Length of new undefined data Type[1]: size_t |
| Explanation: |
This function is the same as calling ustr_dupx_undef() with the current set of default options. |
|
Function: ustr_dup()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Pointer to a constant Ustr string Type[1]: const struct Ustr * |
| Explanation: |
This function tries to increase the reference count on the passed Ustr string, and if that succeeds returns that as an argument. If that fails it tries creates a new Ustr string that looks identical to the old Ustr string, apart from the reference count. |
| Note: |
Because the new Ustr string is configured identically to the old Ustr string this means the result can be very different to what you get if you call ustr_dup_buf() with ustr_cstr() and ustr_len() from the original string where the configuration would be whatever the default is. Esp. worth of note is that if you ustr_dup() a Ustr string with an explicit size of 900 but a length of 1, and the reference count is full the returned Ustr string will have a size of 900 bytes and so will have allocated a little over that. ustr_dup_buf(), even with a sized configuration would only allocate about 12 bytes and have a size a little less than that. |
|
Function: ustr_dupx()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Pointer to a constant Ustr string Type[5]: const struct Ustr * |
| Explanation: |
This function tries to add a reference if the value of the size, reference bytes, exact memory allocations and ENOMEM are the same as those in the passed Ustr string (Parameter[5]). If the comparison fails or the addition of a reference fails it works like ustr_dupx_buf() using ustr_cstr() and ustr_len(). |
|
Function: ustr_sc_dup()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Explanation: |
This function works like calling ustr_dup(), but if the reference count is maxed out then and so a new Ustr string has been allocated then that is stored in the passed argument (Parameter[1]) and the "old" Ustr string is returned. |
| Note: |
The reason to use this is that if you have a "main" Ustr string pointer that a lot of things are getting references too then when the reference count maxes out you'll degrade into worst case behaviour which acts as though there are no reference counts. This function stops that problem. As an example, if you have a 1 byte reference count and have 255 * 2 references then using ustr_dup() will create 256 Ustr strings using this function will create 4 Ustr strings. |
|
Function: ustr_sc_dupx()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: A pointer to a pointer to a Ustr string Type[5]: struct Ustr ** |
| Explanation: |
This function works like calling ustr_dupx(), but if the reference count is maxed out then and so a new Ustr string is allocated then that is stored in the passed argument (Parameter[1]) and the "old" Ustr string is returned. If the configurations of the new Ustr string and the old Ustr string are not the same, this function works identically to ustr_dupx(). |
| Note: |
The reason to use this is that if you have a "main" Ustr string pointer that a lot of things are getting references too then when the reference count maxes out you'll degrade into worst case behaviour which acts as though there are no reference counts. This function stops that problem. As an example, if you have a 1 byte reference count and have 255 * 2 references then using ustr_dupx() will create 256 Ustr strings using this function will create 4 Ustr strings. |
|
Function: ustr_dup_buf()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Pointer to data Type[1]: const void * |
| Parameter[2]: Length of data Type[2]: size_t |
| Explanation: |
This function works as if you had called ustr_dup_undef() and then copied the data into the new undefined space. |
|
Function: ustr_dupx_buf()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Pointer to data Type[5]: const void * |
| Parameter[6]: Length of data Type[6]: size_t |
| Explanation: |
This function works as if you had called ustr_dupx_undef() and then copied the data into the new undefined space. |
|
Function: ustr_dup_cstr()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Pointer to constant C-style string Type[1]: const char * |
| Explanation: |
This function works as if you had called ustr_dup_buf() and passed strlen() as the length. |
|
Function: ustr_dupx_cstr()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Pointer to constant C-style string Type[5]: const char * |
| Explanation: |
This function works as if you had called ustr_dupx_buf() and passed strlen() as the length. |
|
Function: USTR_DUP_OSTR()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: A constant C-style string Type[1]: const char [] |
| Explanation: |
This function works as if you had called ustr_dup_buf() and passed sizeof() - 1 as the length. |
|
Function: USTR_DUP_OBJ()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: A symbol Type[1]: ... |
| Explanation: |
This function works as if you had called ustr_dup_buf() and passed sizeof() as the length. |
| Note: |
In most cases you'll want to use USTR_DUP_OSTR(). |
|
Function: ustr_dup_subustr()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: A pointer to a constant Ustr string Type[1]: const struct Ustr * |
| Parameter[2]: Position in the Ustr Type[2]: size_t |
| Parameter[3]: Length to add from the Ustr Type[3]: size_t |
| Explanation: |
This function mostly works as if you had called ustr_dup_buf() with the ustr_cstr() + position - 1 and length values of the Ustr string to be added. |
| Note: |
If the position is 1 and the length is the length of the Ustr string then it just calls ustr_dup(). |
|
Function: ustr_dupx_subustr()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: A pointer to a constant Ustr string Type[5]: const struct Ustr * |
| Parameter[6]: Position in the Ustr Type[6]: size_t |
| Parameter[7]: Length to add from the Ustr Type[7]: size_t |
| Explanation: |
This function mostly works as if you had called ustr_dupx_buf() with the ustr_cstr() + position - 1 and length values of the Ustr string to be added. |
| Note: |
If the position is 1 and the length is the length of the Ustr string then it just calls ustr_dupx(). |
|
Function: ustr_dup_rep_chr()
Returns: A pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Byte value of data Type[1]: char |
| Parameter[2]: Length of bytes as data Type[2]: size_t |
| Explanation: |
This function works as if you had called ustr_dup_undef() and then copied the byte value to each position. |
|
Function: ustr_dupx_rep_chr()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Byte value of data Type[5]: char |
| Parameter[6]: Length of bytes as data Type[6]: size_t |
| Explanation: |
This function works as if you had called ustr_dupx_undef() and then copied the byte value to each position. |
|
Function: ustr_sc_vjoin()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Separator to go between Ustr strings Type[1]: const struct Ustr * |
| Parameter[2]: A pointer to the first constant Ustr string Type[2]: const struct Ustr * |
| Parameter[3]: A pointer to the second constant Ustr string Type[3]: const struct Ustr * |
| Parameter[4]: Variable argument list variable, from va_start() Type[4]: va_list |
| Explanation: |
This function works as if you called ustr_dup() on the first Ustr string (Parameter[2]), and then ustr_add() on the separator (Parameter[1]) followed by ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. |
| Note: |
This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. |
|
Function: ustr_sc_join()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Separator to go between Ustr strings Type[1]: const struct Ustr * |
| Parameter[2]: A pointer to the first constant Ustr string Type[2]: const struct Ustr * |
| Parameter[3]: A pointer to the second constant Ustr string Type[3]: const struct Ustr * |
| Parameter[4]: Zero or more pointers to constant Ustr strings and then USTR_NULL Type[4]: ... |
| Explanation: |
This function calls va_start() to get a variable argument list and then calls ustr_sc_vjoin(). |
| Note: |
This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. |
|
Function: ustr_sc_vjoinx()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Separator to go between Ustr strings Type[5]: const struct Ustr * |
| Parameter[6]: A pointer to the first constant Ustr string Type[6]: const struct Ustr * |
| Parameter[7]: A pointer to the second constant Ustr string Type[7]: const struct Ustr * |
| Parameter[8]: Variable argument list variable, from va_start() Type[8]: va_list |
| Explanation: |
This function works as if you called ustr_dupx() on the first Ustr string (Parameter[2]), and then ustr_add() on the separator (Parameter[1]) followed by ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. |
| Note: |
This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. |
|
Function: ustr_sc_joinx()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Separator to go between Ustr strings Type[5]: const struct Ustr * |
| Parameter[6]: A pointer to the first constant Ustr string Type[6]: const struct Ustr * |
| Parameter[7]: A pointer to the second constant Ustr string Type[7]: const struct Ustr * |
| Parameter[8]: Zero or more pointers to constant Ustr strings and then USTR_NULL Type[8]: ... |
| Explanation: |
This function calls va_start() to get a variable argument list and then calls ustr_sc_vjoinx(). |
|
Function: ustr_sc_vconcat()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: A pointer to the first constant Ustr string Type[1]: const struct Ustr * |
| Parameter[2]: Variable argument list variable, from va_start() Type[2]: va_list |
| Explanation: |
This function works as if you called ustr_dup() on the first Ustr string (Parameter[1]), and then ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. |
| Note: |
This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. |
|
Function: ustr_sc_concat()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: A pointer to the first constant Ustr string Type[1]: const struct Ustr * |
| Parameter[2]: Zero or more pointers to constant Ustr strings and then USTR_NULL Type[2]: ... |
| Explanation: |
This function calls va_start() to get a variable argument list and then calls ustr_sc_vconcat(). |
|
Function: ustr_sc_vconcatx()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: A pointer to the first constant Ustr string Type[5]: const struct Ustr * |
| Parameter[6]: Variable argument list variable, from va_start() Type[6]: va_list |
| Explanation: |
This function works as if you called ustr_dupx() on the first Ustr string (Parameter[1]), and then ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. |
| Note: |
This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. |
|
Function: ustr_sc_concatx()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: A pointer to the first constant Ustr string Type[5]: const struct Ustr * |
| Parameter[6]: Zero or more pointers to constant Ustr strings and then USTR_NULL Type[6]: ... |
| Explanation: |
This function calls va_start() to get a variable argument list and then calls ustr_sc_vconcatx(). |
Deleting a Ustr, or data within a Ustr |
|
Function: ustr_free()
Returns: Nothing Type: void |
| Parameter[1]: Pointer to a Ustr Type[1]: struct Ustr * |
| Explanation: |
This function decrements the reference count on a Ustr, if there is one, and free's it if it is allocated and the reference count becomes zero. |
| Note: |
This function does nothing if passed USTR_NULL. |
|
Function: ustrp_free()
Returns: Nothing Type: void |
| Parameter[1]: Pointer to a Ustr pool object Type[1]: struct Ustr_pool * |
| Parameter[2]: Pointer to a Ustrp (pool allocated Ustr) Type[2]: struct Ustrp * |
| Explanation: |
This function works like ustr_free() but calls the pool_free member function of the Ustr_pool (Parameter[1]) instead of the ustr system free. |
|
Function: ustr_sc_free()
Returns: Nothing Type: void |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Explanation: |
This function calls ustr_free() and then sets the pointer (Parameter[1]) to USTR_NULL, which is a noop when passed to ustr_free(). This can be used to help prevent "double free" errors. |
| Note: |
While the point to the pointer must be non-NULL, this function also accepts a NULL ustr and does nothing. So you can pass the same pointer to this function multiple times and only the first one will do anything. |
|
Function: ustr_sc_free2()
Returns: Nothing Type: void |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Pointer to a Ustr string Type[2]: struct Ustr * |
| Explanation: |
This function works like ustr_sc_free() but instead of setting the pointer (Parameter[1]) to USTR_NULL it sets it to the Ustr string (Parameter[2]). |
| Note: |
While the point to the pointer must be non-NULL, this function also accepts a NULL ustr to be free'd and does nothing. So you can pass the same pointer to ustr_sc_free() and then this function safely. The passed value (Parameter[2]) shouldn't be USTR_NULL, and in debugging mode the function will assert() that it isn't. |
|
Function: ustr_sc_free_shared()
Returns: Nothing Type: void |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Explanation: |
This function is a simple way to "free" a Ustr string that has been shared (ustr_shared() returns USTR_TRUE), normally ustr_free() is ignored on a shared Ustr string. It just calls ustr_setf_owner() and then ustr_sc_free(). |
|
Function: ustr_del()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Length to delete from the Ustr Type[2]: size_t |
| Explanation: |
This function deletes data from the end of Ustr, possibly re-sizing the Ustr at the same time. |
| Note: |
The Ustr is never re-sized when the size is stored explicitly, so the pointer never changes. |
|
Function: ustr_del_subustr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position in the Ustr Type[2]: size_t |
| Parameter[3]: Length to delete from the Ustr Type[3]: size_t |
| Explanation: |
This function works like ustr_del() but can delete an arbitrary section of the Ustr. |
|
Function: ustr_sc_del()
Returns: Nothing Type: void |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Explanation: |
This function is like calling ustr_del() with ustr_len() as the length, however if that fails it does a ustr_free() and then sets the pointer to USTR(""). |
| Note: |
While the benifit is that you don't have to check for memory failure errors, if there is a memory failure and you have a non-default configuration the configuration will revert back to the default. |
Adding data to a Ustr |
|
Function: ustr_add_undef()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Length of new undefined data Type[2]: size_t |
| Explanation: |
The Ustr string is expanded (possibly reallocated) so that it can contain length (Parameter[2]) extra data, if the length is not zero the Ustr will be writable. Or it'll return USTR_FALSE (zero) on failure. |
|
Function: ustr_add_buf()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Pointer to data Type[2]: const void * |
| Parameter[3]: Length of data Type[3]: size_t |
| Explanation: |
This function works as if you had called ustr_add_undef() and then copied the data into the new undefined space. |
|
Function: ustr_add_cstr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Pointer to constant C-style string Type[2]: const char * |
| Explanation: |
This function works as if you had called ustr_add_buf() and passed strlen() as the length. |
|
Function: USTR_ADD_OSTR()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A constant C-style string Type[2]: const char [] |
| Explanation: |
This function works as if you had called ustr_add_buf() and passed sizeof() - 1 as the length. |
|
Function: USTR_ADD_OBJ()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A symbol Type[2]: ... |
| Explanation: |
This function works as if you had called ustr_add_buf() and passed sizeof() as the length. |
| Note: |
In most cases you'll want to use USTR_ADD_OSTR(). |
|
Function: ustr_add()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant Ustr string Type[2]: const struct Ustr * |
| Explanation: |
This function mostly works as if you had called ustr_add_buf() with the ustr_cstr() and ustr_len() values of the Ustr string to be added. |
| Note: |
If the Ustr string is zero length and isn't writable this function may just add a reference, this is fine for Ustr strings that are "constant" because if the Ustr is read-only then the memory will not be written to. |
|
Function: ustr_add_subustr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant Ustr string Type[2]: const struct Ustr * |
| Parameter[3]: Position in the Ustr Type[3]: size_t |
| Parameter[4]: Length to add from the Ustr Type[4]: size_t |
| Explanation: |
This function mostly works as if you had called ustr_add_buf() with the ustr_cstr() + position - 1 and length values of the Ustr string to be added. The exception being if you add a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr, but this function just works. |
| Note: |
If the position is 1 and the length is the length of the Ustr string then it just calls ustr_add(). |
|
Function: ustr_add_rep_chr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Byte value of data Type[2]: char |
| Parameter[3]: Length of bytes as data Type[3]: size_t |
| Explanation: |
This function works as if you had called ustr_add_undef() and then copied the byte value to each position. |
Setting a Ustr to some data |
|
Function: ustr_set_undef()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: size_t Type[2]: size_t |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and the ustr_add_undef(). |
|
Function: ustr_set_empty()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Explanation: |
This function works as if you had called ustr_del() for the entire string, however the string will be allocated if this completes. |
|
Function: ustr_set_buf()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Buffer containting data Type[2]: const void * |
| Parameter[3]: Length of Buffer Type[3]: size_t |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and the ustr_add_buf(). |
|
Function: ustr_set_cstr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant C-style string Type[2]: const char * |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and then ustr_add_cstr(). |
|
Function: USTR_SET_OSTR()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A constant C-style string Type[2]: const char [] |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and then USTR_ADD_OSTR(). |
|
Function: USTR_SET_OBJ()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A symbol Type[2]: ... |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and then USTR_ADD_OBJ(). |
| Note: |
In most cases you'll want to use USTR_SET_OSTR(). |
|
Function: ustr_set()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant Ustr string Type[2]: const struct Ustr * |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and the ustr_add(). |
|
Function: ustr_set_subustr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant Ustr string Type[2]: const struct Ustr * |
| Parameter[3]: Position in the Ustr Type[3]: size_t |
| Parameter[4]: Length to set from the Ustr Type[4]: size_t |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and the ustr_add_subustr(). The exception being if you set a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr data, but this function just works. |
|
Function: ustr_set_rep_chr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Byte value of data Type[2]: char |
| Parameter[3]: Length of bytes as data Type[3]: size_t |
| Explanation: |
This function works as if you had called ustr_del() for the entire string and the ustr_add_rep_chr(). |
Inserting data into a Ustr |
|
Function: ustr_ins_undef()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[3]: Length of new undefined data Type[3]: size_t |
| Explanation: |
The Ustr string is expanded (possibly reallocated) so that it can contain length (Parameter[2]) extra data, from after the required position. If the length is not zero the Ustr will be writable. Or it'll return USTR_FALSE (zero) on failure. The data in the Ustr is moved as needed to put the new data at position (Parameter[2]) + 1. |
|
Function: ustr_ins_buf()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[3]: Pointer to data Type[3]: const void * |
| Parameter[4]: Length of data Type[4]: size_t |
| Explanation: |
This function works as if you had called ustr_ins_undef() and then copied the data into the new undefined space. |
|
Function: ustr_ins_cstr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[3]: Pointer to constant C-style string Type[3]: const char * |
| Explanation: |
This function works as if you had called ustr_ins_buf() and passed strlen() as the length. |
|
Function: USTR_INS_OSTR()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[3]: A constant C-style string Type[3]: const char [] |
| Explanation: |
This function works as if you had called ustr_ins_buf() and passed sizeof() - 1 as the length. |
|
Function: USTR_INS_OBJ()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[3]: A symbol Type[3]: ... |
| Explanation: |
This function works as if you had called ustr_ins_buf() and passed sizeof() as the length. |
| Note: |
In most cases you'll want to use USTR_INS_OSTR(). |
|
Function: ustr_ins()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[3]: A pointer to a constant Ustr string Type[3]: const struct Ustr * |
| Explanation: |
This function works as if you had called ustr_ins_buf() with the ustr_cstr() and ustr_len() values of the Ustr string to be added. |
|
Function: ustr_ins_subustr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[2]: A pointer to a constant Ustr string Type[2]: const struct Ustr * |
| Parameter[3]: Position in the Ustr Type[3]: size_t |
| Parameter[4]: Length to ins from the Ustr Type[4]: size_t |
| Explanation: |
This function mostly as if you had called ustr_ins_buf() with the ustr_cstr() + position - 1 and length values of the Ustr string to be insed. The exception being if you insert a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr data, but this function just works. |
|
Function: ustr_ins_rep_chr()
Returns: Success or failure Type: int |
| Parameter[1]: Pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Position after which the data should be added Type[2]: size_t |
| Parameter[2]: Byte value of data Type[2]: char |
| Parameter[3]: Length of bytes as data Type[3]: size_t |
| Explanation: |
This function works as if you had called ustr_ins_undef() and then copied the byte value to each position. |
Adding, duplicating and setting formatted data to a Ustr |
|
Function: ustr_add_vfmt_lim()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Limit of data to add Type[2]: size_t |
| Parameter[3]: A pointer to a constant C-style string Type[3]: const char * |
| Parameter[4]: Variable argument list variable, from va_start() Type[4]: va_list |
| Explanation: |
This function works like calling the system vsnprintf() with the limit (Parameter[2]) as the limit to vsnprintf() and then calling ustr_add_buf(). |
|
Function: ustr_add_vfmt()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant C-style string Type[2]: const char * |
| Parameter[3]: Variable argument list variable, from va_start() Type[3]: va_list |
| Explanation: |
This function works like calling the system vsnprintf() and then calling ustr_add_buf(). |
|
Function: ustr_add_fmt_lim()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Limit of data to add Type[2]: size_t |
| Parameter[3]: A pointer to a constant C-style string Type[3]: const char * |
| Parameter[4]: Options depending on value of Parameter[3] Type[4]: ... |
| Explanation: |
This function works like calling the system snprintf() with the limit (Parameter[2]) as the limit to snprintf() and then calling ustr_add_buf(). |
|
Function: ustr_add_fmt()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant C-style string Type[2]: const char * |
| Parameter[3]: Options depending on value of Parameter[2] Type[3]: ... |
| Explanation: |
This function works like calling the system snprintf() and then calling ustr_add_buf(). |
|
Function: ustr_dup_vfmt_lim()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Limit of data to dup Type[1]: size_t |
| Parameter[2]: Pointer to a constant Ustr string Type[2]: const char * |
| Parameter[3]: Variable argument list variable, from va_start() Type[3]: va_list |
| Explanation: |
This function works like calling the system vsnprintf() with the limit (Parameter[2]) as the limit to vsnprintf() and then calling ustr_dup_buf(). |
|
Function: ustr_dup_vfmt()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Limit of data to dup Type[1]: size_t |
| Parameter[2]: Pointer to a constant Ustr string Type[2]: const char * |
| Parameter[3]: Variable argument list variable, from va_start() Type[3]: va_list |
| Explanation: |
This function works like calling the system vsnprintf() and then calling ustr_dup_buf(). |
|
Function: ustr_dup_fmt_lim()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Limit of data to dup Type[1]: size_t |
| Parameter[2]: Pointer to a constant Ustr string Type[2]: const char * |
| Parameter[3]: Options depending on value of Parameter[2] Type[3]: ... |
| Explanation: |
This function works like calling the system snprintf() with the limit (Parameter[2]) as the limit to snprintf() and then calling ustr_dup_buf(). |
|
Function: ustr_dup_fmt()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Pointer to a constant Ustr string Type[1]: const char * |
| Parameter[2]: Options depending on value of Parameter[1] Type[2]: ... |
| Explanation: |
This function works like calling the system snprintf() and then calling ustr_dup_buf(). |
|
Function: ustr_dupx_fmt_lim()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Limit of data to dup Type[5]: size_t |
| Parameter[6]: Pointer to a constant Ustr string Type[6]: const char * |
| Parameter[7]: Options depending on value of Parameter[6] Type[7]: ... |
| Explanation: |
This function works like calling the system snprintf() with the limit (Parameter[2]) as the limit to snprintf() and then calling ustr_dupx_buf(). |
|
Function: ustr_dupx_fmt()
Returns: Pointer to a Ustr string Type: struct Ustr * |
| Parameter[1]: Size of allocated storage Type[1]: size_t |
| Parameter[2]: Number of bytes to use for reference count Type[2]: size_t |
| Parameter[3]: Exact memory allocations Type[3]: int |
| Parameter[4]: ENOMEM, memory error flag Type[4]: int |
| Parameter[5]: Pointer to a constant Ustr string Type[5]: const char * |
| Parameter[6]: Options depending on value of Parameter[5] Type[6]: ... |
| Explanation: |
This function works like calling the system snprintf() and then calling ustr_dup_bufx(). |
|
Function: ustr_set_vfmt_lim()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Limit of data to set Type[2]: size_t |
| Parameter[3]: A pointer to a constant C-style string Type[3]: const char * |
| Parameter[4]: Variable argument list variable, from va_start() Type[4]: va_list |
| Explanation: |
This function works like calling ustr_del() for all the data and then ustr_add_vfmt_lim(). |
|
Function: ustr_set_vfmt()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant C-style string Type[2]: const char * |
| Parameter[3]: Variable argument list variable, from va_start() Type[3]: va_list |
| Explanation: |
This function works like calling ustr_del() for all the data and then ustr_add_vfmt(). |
|
Function: ustr_set_fmt_lim()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: Limit of data to set Type[2]: size_t |
| Parameter[3]: A pointer to a constant C-style string Type[3]: const char * |
| Parameter[4]: Options depending on value of Parameter[3] Type[4]: ... |
| Explanation: |
This function works like calling ustr_del() for all the data and then ustr_add_fmt_lim(). |
|
Function: ustr_set_fmt()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2]: A pointer to a constant C-style string Type[2]: const char * |
| Parameter[3]: Options depending on value of Parameter[2] Type[3]: ... |
| Explanation: |
This function works like calling ustr_del() for all the data and then ustr_add_fmt(). |
|
Function: ustr_ins_vfmt_lim()
Returns: Success or failure Type: int |
| Parameter[1]: A pointer to a pointer to a Ustr string Type[1]: struct Ustr ** |
| Parameter[2] |