api: return pointer to string in function string_dyn_free() if argument "free_string" is 0

v2.8-utf8proc
Sébastien Helleu 2017-04-01 12:04:28 +02:00
parent f855b6b0f3
commit af138840b3
7 changed files with 39 additions and 9 deletions

View File

@ -2335,7 +2335,7 @@ Prototype:
[source,C]
----
void weechat_dyn_free (char **string, int free_string);
char *weechat_dyn_free (char **string, int free_string);
----
Arguments:
@ -2344,6 +2344,10 @@ Arguments:
* _free_string_: free the string itself; if 0, the content of _*string_ remains
valid after the call to this function
Return value:
* string pointer if _free_string_ is 0, otherwise NULL
C example:
[source,C]

View File

@ -2378,7 +2378,7 @@ Prototype :
[source,C]
----
void weechat_dyn_free (char **string, int free_string);
char *weechat_dyn_free (char **string, int free_string);
----
Paramètres :
@ -2387,6 +2387,10 @@ Paramètres :
* _free_string_ : libérer la chaîne elle-même ; si 0, le contenu de _*string_
reste valide après l'appel à cette fonction
Valeur de retour :
* pointeur vers la chaîne si _free_string_ vaut 0, sinon NULL
Exemple en C :
[source,C]

View File

@ -2425,7 +2425,7 @@ Prototipo:
[source,C]
----
void weechat_dyn_free (char **string, int free_string);
char *weechat_dyn_free (char **string, int free_string);
----
Argomenti:
@ -2435,6 +2435,11 @@ Argomenti:
* _free_string_: free the string itself; if 0, the content of _*string_ remains
valid after the call to this function
Valore restituito:
// TRANSLATION MISSING
* string pointer if _free_string_ is 0, otherwise NULL
Esempio in C:
[source,C]

View File

@ -2343,7 +2343,7 @@ _WeeChat バージョン 1.8 以上で利用可_
[source,C]
----
void weechat_dyn_free (char **string, int free_string);
char *weechat_dyn_free (char **string, int free_string);
----
引数:
@ -2352,6 +2352,11 @@ void weechat_dyn_free (char **string, int free_string);
* _free_string_: 文字列の解放; 0 を指定することで、この関数を呼び出した後でも
_*string_ が指すアドレスのメモリを確保したままにできます。
戻り値:
// TRANSLATION MISSING
* string pointer if _free_string_ is 0, otherwise NULL
C 言語での使用例:
[source,C]

View File

@ -3433,22 +3433,34 @@ string_dyn_concat (char **string, const char *add)
* If free_string == 1, the string itself is freed in the structure.
* Otherwise the pointer (*string) remains valid after this call, and
* the caller must manually free the string with a call to free().
*
* Returns the pointer to the string if "free_string" is 0 (string
* pointer is still valid), or NULL if "free_string" is 1 (string
* has been freed).
*/
void
char *
string_dyn_free (char **string, int free_string)
{
struct t_string_dyn *ptr_string_dyn;
char *ptr_string;
if (!string || !*string)
return;
return NULL;
ptr_string_dyn = (struct t_string_dyn *)string;
if (free_string)
{
free (ptr_string_dyn->string);
return NULL;
}
ptr_string = ptr_string_dyn->string;
free (ptr_string_dyn);
return ptr_string;
}
/*

View File

@ -121,7 +121,7 @@ extern void string_shared_free (const char *string);
extern char **string_dyn_alloc (int size_alloc);
extern int string_dyn_copy (char **string, const char *new_string);
extern int string_dyn_concat (char **string, const char *add);
extern void string_dyn_free (char **string, int free_string);
extern char *string_dyn_free (char **string, int free_string);
extern void string_end ();
#endif /* WEECHAT_STRING_H */

View File

@ -59,7 +59,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20170312-01"
#define WEECHAT_PLUGIN_API_VERSION "20170401-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -328,7 +328,7 @@ struct t_weechat_plugin
char **(*string_dyn_alloc) (int size_alloc);
int (*string_dyn_copy) (char **string, const char *new_string);
int (*string_dyn_concat) (char **string, const char *add);
void (*string_dyn_free) (char **string, int free_string);
char *(*string_dyn_free) (char **string, int free_string);
/* UTF-8 strings */
int (*utf8_has_8bits) (const char *string);