mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
Issue 9869 - replace malloc and memset with ast_calloc, and other coding guidelines changes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
14
main/io.c
14
main/io.c
@@ -87,12 +87,12 @@ struct io_context *io_context_create(void)
|
||||
tmp->current_ioc = -1;
|
||||
|
||||
if (!(tmp->fds = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->fds)))) {
|
||||
free(tmp);
|
||||
ast_free(tmp);
|
||||
tmp = NULL;
|
||||
} else {
|
||||
if (!(tmp->ior = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->ior)))) {
|
||||
free(tmp->fds);
|
||||
free(tmp);
|
||||
ast_free(tmp->fds);
|
||||
ast_free(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
}
|
||||
@@ -104,11 +104,11 @@ void io_context_destroy(struct io_context *ioc)
|
||||
{
|
||||
/* Free associated memory with an I/O context */
|
||||
if (ioc->fds)
|
||||
free(ioc->fds);
|
||||
ast_free(ioc->fds);
|
||||
if (ioc->ior)
|
||||
free(ioc->ior);
|
||||
ast_free(ioc->ior);
|
||||
|
||||
free(ioc);
|
||||
ast_free(ioc);
|
||||
}
|
||||
|
||||
/*! \brief
|
||||
@@ -250,7 +250,7 @@ int ast_io_remove(struct io_context *ioc, int *_id)
|
||||
for (x = 0; x < ioc->fdcnt; x++) {
|
||||
if (ioc->ior[x].id == _id) {
|
||||
/* Free the int immediately and set to NULL so we know it's unused now */
|
||||
free(ioc->ior[x].id);
|
||||
ast_free(ioc->ior[x].id);
|
||||
ioc->ior[x].id = NULL;
|
||||
ioc->fds[x].events = 0;
|
||||
ioc->fds[x].revents = 0;
|
||||
|
Reference in New Issue
Block a user