diff options
Diffstat (limited to 'main/snprintf.h')
| -rw-r--r-- | main/snprintf.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/main/snprintf.h b/main/snprintf.h index b3ea02ee82..3ba50259ff 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -21,7 +21,7 @@ /* -Comparing: sprintf, snprintf, slprintf, spprintf +Comparing: sprintf, snprintf, slprintf, spprintf sprintf offers the ability to make a lot of failures since it does not know the size of the buffer it uses. Therefore usage of sprintf often @@ -34,19 +34,19 @@ snprintf knows the buffers size and will not write behind it. But you will before beeing able to call the function. In other words you must be sure that you really know the maximum size of the buffer required. A bad thing is having a big maximum while in most cases you would - only need a small buffer. If the size of the resulting string is + only need a small buffer. If the size of the resulting string is longer or equal to the buffer size than the buffer is not terminated. - The function also returns the number of chars not including the + The function also returns the number of chars not including the terminating \0 that were needed to fully comply to the print request. -slprintf same as snprintf with the difference that it actually returns the +slprintf same as snprintf with the difference that it actually returns the length printed not including the terminating \0. spprintf is the dynamical version of snprintf. It allocates the buffer in size as needed and allows a maximum setting as snprintf (turn this feature off by setting max_len to 0). spprintf is a little bit slower than - snprintf and offers possible memory leakes if you miss freeing the - buffer allocated by the function. Therfore this function should be + snprintf and offers possible memory leakes if you miss freeing the + buffer allocated by the function. Therfore this function should be used where either no maximum is known or the maximum is much bigger than normal size required. spprintf allways terminates the buffer. @@ -61,8 +61,8 @@ Example: | | if (!buffer) | | return OUT_OF_MEMORY // sprintf allways terminates | // manual termination of | // spprintf allays terminates buffer - // buffer | // buffer *IS* required | - | buffer[MAX-1] = 0; | + // buffer | // buffer *IS* required | + | buffer[MAX-1] = 0; | action_with_buffer(buffer); | action_with_buffer(buffer); | action_with_buffer(buffer); | | efree(buffer); */ |
