Replace X-allocation functions with their C89 counterparts
The only remaining X-functions used in server are XNF*, the rest is converted to plain alloc/calloc/realloc/free/strdup. X* functions are still exported from server and x* macros are still defined in header file, so both ABI and API are not affected by this change. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
20
os/xsha1.c
20
os/xsha1.c
@@ -12,7 +12,7 @@
|
||||
|
||||
void *x_sha1_init(void)
|
||||
{
|
||||
SHA1_CTX *ctx = xalloc(sizeof(*ctx));
|
||||
SHA1_CTX *ctx = malloc(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
SHA1Init(ctx);
|
||||
@@ -30,7 +30,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
|
||||
{
|
||||
SHA1_CTX *sha1_ctx = ctx;
|
||||
SHA1Final(result, sha1_ctx);
|
||||
xfree(sha1_ctx);
|
||||
free(sha1_ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
|
||||
|
||||
void *x_sha1_init(void)
|
||||
{
|
||||
CC_SHA1_CTX *ctx = xalloc(sizeof(*ctx));
|
||||
CC_SHA1_CTX *ctx = malloc(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
CC_SHA1_Init(ctx);
|
||||
@@ -58,7 +58,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
|
||||
{
|
||||
CC_SHA1_CTX *sha1_ctx = ctx;
|
||||
CC_SHA1_Final(result, sha1_ctx);
|
||||
xfree(sha1_ctx);
|
||||
free(sha1_ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
|
||||
|
||||
void *x_sha1_init(void)
|
||||
{
|
||||
sha1_ctx *ctx = xalloc(sizeof(*ctx));
|
||||
sha1_ctx *ctx = malloc(sizeof(*ctx));
|
||||
if(!ctx)
|
||||
return NULL;
|
||||
sha1_begin(ctx);
|
||||
@@ -123,7 +123,7 @@ int x_sha1_update(void *ctx, void *data, int size)
|
||||
int x_sha1_final(void *ctx, unsigned char result[20])
|
||||
{
|
||||
sha1_end(result, ctx);
|
||||
xfree(ctx);
|
||||
free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -135,12 +135,12 @@ int x_sha1_final(void *ctx, unsigned char result[20])
|
||||
void *x_sha1_init(void)
|
||||
{
|
||||
int ret;
|
||||
SHA_CTX *ctx = xalloc(sizeof(*ctx));
|
||||
SHA_CTX *ctx = malloc(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
ret = SHA1_Init(ctx);
|
||||
if (!ret) {
|
||||
xfree(ctx);
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
@@ -152,7 +152,7 @@ int x_sha1_update(void *ctx, void *data, int size)
|
||||
SHA_CTX *sha_ctx = ctx;
|
||||
ret = SHA1_Update(sha_ctx, data, size);
|
||||
if (!ret)
|
||||
xfree(sha_ctx);
|
||||
free(sha_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ int x_sha1_final(void *ctx, unsigned char result[20])
|
||||
int ret;
|
||||
SHA_CTX *sha_ctx = ctx;
|
||||
ret = SHA1_Final(result, sha_ctx);
|
||||
xfree(sha_ctx);
|
||||
free(sha_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user