mirror of
https://github.com/transmission/transmission.git
synced 2025-12-23 20:08:43 +00:00
Use tr_realloc (BSD reallocf-alike) instead of plain realloc
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h> /* realloc () */
|
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
|
|
||||||
#include "transmission.h"
|
#include "transmission.h"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h> /* tr_renew () -> realloc () */
|
|
||||||
#include <string.h> /* memmove */
|
#include <string.h> /* memmove */
|
||||||
|
|
||||||
#include "ptrarray.h"
|
#include "ptrarray.h"
|
||||||
|
|||||||
@@ -129,6 +129,15 @@ tr_malloc0 (size_t size)
|
|||||||
return size ? calloc (1, size) : NULL;
|
return size ? calloc (1, size) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
tr_realloc (void * p, size_t size)
|
||||||
|
{
|
||||||
|
void * result = size != 0 ? realloc (p, size) : NULL;
|
||||||
|
if (result == NULL)
|
||||||
|
tr_free (p);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tr_free (void * p)
|
tr_free (void * p)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -252,6 +252,9 @@ void* tr_malloc (size_t size);
|
|||||||
/** @brief Portability wrapper around calloc () in which `0' is a safe argument */
|
/** @brief Portability wrapper around calloc () in which `0' is a safe argument */
|
||||||
void* tr_malloc0 (size_t size);
|
void* tr_malloc0 (size_t size);
|
||||||
|
|
||||||
|
/** @brief Portability wrapper around reallocf () in which `0' is a safe argument */
|
||||||
|
void * tr_realloc (void * p, size_t size);
|
||||||
|
|
||||||
/** @brief Portability wrapper around free () in which `NULL' is a safe argument */
|
/** @brief Portability wrapper around free () in which `NULL' is a safe argument */
|
||||||
void tr_free (void * p);
|
void tr_free (void * p);
|
||||||
|
|
||||||
@@ -270,7 +273,7 @@ void* tr_memdup (const void * src, size_t byteCount);
|
|||||||
((struct_type *) tr_malloc0 (sizeof (struct_type) * ((size_t)(n_structs))))
|
((struct_type *) tr_malloc0 (sizeof (struct_type) * ((size_t)(n_structs))))
|
||||||
|
|
||||||
#define tr_renew(struct_type, mem, n_structs) \
|
#define tr_renew(struct_type, mem, n_structs) \
|
||||||
((struct_type *) realloc ((mem), sizeof (struct_type) * ((size_t)(n_structs))))
|
((struct_type *) tr_realloc ((mem), sizeof (struct_type) * ((size_t)(n_structs))))
|
||||||
|
|
||||||
void* tr_valloc (size_t bufLen);
|
void* tr_valloc (size_t bufLen);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user