[asterisk-commits] seanbright: branch group/asterisk-cpp r168403 - /team/group/asterisk-cpp/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Jan 10 18:29:57 CST 2009
Author: seanbright
Date: Sat Jan 10 18:29:57 2009
New Revision: 168403
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168403
Log:
io.c and sched.c compile now
Modified:
team/group/asterisk-cpp/main/io.c
team/group/asterisk-cpp/main/sched.c
Modified: team/group/asterisk-cpp/main/io.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/io.c?view=diff&rev=168403&r1=168402&r2=168403
==============================================================================
--- team/group/asterisk-cpp/main/io.c (original)
+++ team/group/asterisk-cpp/main/io.c Sat Jan 10 18:29:57 2009
@@ -73,7 +73,7 @@
{
struct io_context *tmp = NULL;
- if (!(tmp = ast_malloc(sizeof(*tmp))))
+ if (!(tmp = (struct io_context *) ast_malloc(sizeof(*tmp))))
return NULL;
tmp->needshrink = 0;
@@ -81,11 +81,11 @@
tmp->maxfdcnt = GROW_SHRINK_SIZE/2;
tmp->current_ioc = -1;
- if (!(tmp->fds = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->fds)))) {
+ if (!(tmp->fds = (struct pollfd *) ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->fds)))) {
ast_free(tmp);
tmp = NULL;
} else {
- if (!(tmp->ior = ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->ior)))) {
+ if (!(tmp->ior = (struct io_rec *) ast_calloc(1, (GROW_SHRINK_SIZE / 2) * sizeof(*tmp->ior)))) {
ast_free(tmp->fds);
ast_free(tmp);
tmp = NULL;
@@ -112,16 +112,17 @@
*/
static int io_grow(struct io_context *ioc)
{
- void *tmp;
+ struct io_rec *ior;
DEBUG(ast_debug(1, "io_grow()\n"));
ioc->maxfdcnt += GROW_SHRINK_SIZE;
- if ((tmp = ast_realloc(ioc->ior, (ioc->maxfdcnt + 1) * sizeof(*ioc->ior)))) {
- ioc->ior = tmp;
- if ((tmp = ast_realloc(ioc->fds, (ioc->maxfdcnt + 1) * sizeof(*ioc->fds)))) {
- ioc->fds = tmp;
+ if ((ior = (struct io_rec *) ast_realloc(ioc->ior, (ioc->maxfdcnt + 1) * sizeof(*ioc->ior)))) {
+ struct pollfd *pfd;
+ ioc->ior = ior;
+ if ((pfd = (struct pollfd *) ast_realloc(ioc->fds, (ioc->maxfdcnt + 1) * sizeof(*ioc->fds)))) {
+ ioc->fds = pfd;
} else {
/*
* Failed to allocate enough memory for the pollfd. Not
@@ -176,7 +177,7 @@
ioc->ior[ioc->fdcnt].callback = callback;
ioc->ior[ioc->fdcnt].data = data;
- if (!(ioc->ior[ioc->fdcnt].id = ast_malloc(sizeof(*ioc->ior[ioc->fdcnt].id)))) {
+ if (!(ioc->ior[ioc->fdcnt].id = (int *) ast_malloc(sizeof(*ioc->ior[ioc->fdcnt].id)))) {
/* Bonk if we couldn't allocate an int */
return NULL;
}
@@ -191,7 +192,7 @@
int *ast_io_change(struct io_context *ioc, int *id, int fd, ast_io_cb callback, short events, void *data)
{
/* If this id exceeds our file descriptor count it doesn't exist here */
- if (*id > ioc->fdcnt)
+ if (*id > (int) ioc->fdcnt)
return NULL;
if (fd > -1)
@@ -208,14 +209,14 @@
static int io_shrink(struct io_context *ioc)
{
- int getfrom, putto = 0;
+ unsigned int putto = 0;
/*
* Bring the fields from the very last entry to cover over
* the entry we are removing, then decrease the size of the
* arrays by one.
*/
- for (getfrom = 0; getfrom < ioc->fdcnt; getfrom++) {
+ for (unsigned int getfrom = 0; getfrom < ioc->fdcnt; getfrom++) {
if (ioc->ior[getfrom].id) {
/* In use, save it */
if (getfrom != putto) {
@@ -235,14 +236,12 @@
int ast_io_remove(struct io_context *ioc, int *_id)
{
- int x;
-
if (!_id) {
ast_log(LOG_WARNING, "Asked to remove NULL?\n");
return -1;
}
- for (x = 0; x < ioc->fdcnt; x++) {
+ for (unsigned 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 */
ast_free(ioc->ior[x].id);
@@ -305,13 +304,11 @@
* Print some debugging information via
* the logger interface
*/
- int x;
-
ast_debug(1, "Asterisk IO Dump: %d entries, %d max entries\n", ioc->fdcnt, ioc->maxfdcnt);
ast_debug(1, "================================================\n");
ast_debug(1, "| ID FD Callback Data Events |\n");
ast_debug(1, "+------+------+-----------+-----------+--------+\n");
- for (x = 0; x < ioc->fdcnt; x++) {
+ for (unsigned int x = 0; x < ioc->fdcnt; x++) {
ast_debug(1, "| %.4d | %.4d | %p | %p | %.6x |\n",
*ioc->ior[x].id,
ioc->fds[x].fd,
Modified: team/group/asterisk-cpp/main/sched.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/sched.c?view=diff&rev=168403&r1=168402&r2=168403
==============================================================================
--- team/group/asterisk-cpp/main/sched.c (original)
+++ team/group/asterisk-cpp/main/sched.c Sat Jan 10 18:29:57 2009
@@ -75,14 +75,14 @@
static int sched_cmp(const void *a, const void *b)
{
- const struct sched *as = a;
- const struct sched *bs = b;
+ const struct sched *as = (const struct sched *) a;
+ const struct sched *bs = (const struct sched *) b;
return as->id != bs->id; /* return 0 on a match like strcmp would */
}
static unsigned int sched_hash(const void *obj)
{
- const struct sched *s = obj;
+ const struct sched *s = (const struct sched *) obj;
unsigned int h = s->id;
return h;
}
@@ -91,7 +91,7 @@
{
struct sched_context *tmp;
- if (!(tmp = ast_calloc(1, sizeof(*tmp))))
+ if (!(tmp = (struct sched_context *) ast_calloc(1, sizeof(*tmp))))
return NULL;
ast_mutex_init(&tmp->lock);
@@ -140,7 +140,7 @@
con->schedccnt--;
else
#endif
- tmp = ast_calloc(1, sizeof(*tmp));
+ tmp = (struct sched *) ast_calloc(1, sizeof(*tmp));
return tmp;
}
@@ -320,7 +320,7 @@
{
struct sched tmp,*res;
tmp.id = id;
- res = ast_hashtab_lookup(con->schedq_ht, &tmp);
+ res = (struct sched *) ast_hashtab_lookup(con->schedq_ht, &tmp);
if (res)
return res->data;
return NULL;
@@ -353,7 +353,7 @@
to look up the id in a hashtab, and then have to run thru
a couple thousand entries to remove it from the schedq list! */
tmp.id = id;
- s = ast_hashtab_lookup(con->schedq_ht, &tmp);
+ s = (struct sched *) ast_hashtab_lookup(con->schedq_ht, &tmp);
if (s) {
struct sched *x = AST_DLLIST_REMOVE(&con->schedq, s, list);
@@ -396,7 +396,7 @@
buf[0] = 0;
sprintf(buf, " Highwater = %d\n schedcnt = %d\n", con->highwater, con->schedcnt);
- countlist = ast_calloc(sizeof(int),cbnames->numassocs+1);
+ countlist = (int *) ast_calloc(sizeof(int), cbnames->numassocs + 1);
AST_DLLIST_TRAVERSE(&con->schedq, cur, list) {
/* match the callback to the cblist */
@@ -523,7 +523,7 @@
/* these next 2 lines replace a lookup loop */
tmp.id = id;
- s = ast_hashtab_lookup(con->schedq_ht, &tmp);
+ s = (struct sched *) ast_hashtab_lookup(con->schedq_ht, &tmp);
if (s) {
struct timeval now = ast_tvnow();
More information about the asterisk-commits
mailing list