From f4d61fa7c40b219b6c38b99d599cba51ff68abce Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 27 Oct 2016 10:17:29 -0300 Subject: [PATCH] test --- src/komodo_utils.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 84b278ff7..460f5e8bb 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1139,7 +1139,7 @@ void *mycalloc(uint8_t type,int32_t n,long itemsize) while ( (item= (struct allocitem *)calloc(1,sizeof(struct allocitem) + allocsize + 16)) == 0 ) { char str[65]; - printf("mycalloc.%c: need to wait for memory.(%d,%ld) %s to be available\n",type,n,itemsize,mbstr(str,allocsize)); + printf("mycalloc.%c: need to wait for memory.(%d,%ld) to be available\n",type,n,itemsize); sleep(10); } item->allocsize = (uint32_t)allocsize; @@ -1239,7 +1239,7 @@ void *queue_clone(queue_t *clone,queue_t *queue,int32_t size) { DL_FOREACH(queue->list,item) { - ptr = mycalloc('c',1,sizeof(*ptr)); + ptr = (struct queueitem *)mycalloc('c',1,sizeof(*ptr)); memcpy(ptr,item,size); queue_enqueue(queue->name,clone,ptr,0); } @@ -1259,9 +1259,29 @@ int32_t queue_size(queue_t *queue) return count; } +void *queueitem(char *str) +{ + struct queueitem *item; int32_t n,allocsize; char *data; uint8_t type = 'y'; + n = (uint32_t)strlen(str) + 1; + allocsize = (uint32_t)(sizeof(struct queueitem) + n); + while ( (item= (struct queueitem *)calloc(1,allocsize)) == 0 ) + { + char str[65]; + printf("queueitem: need to wait for memory.(%d,%ld) to be available\n",n,(long)sizeof(*item)); + sleep(10); + } + item->allocsize = (uint32_t)allocsize; + item->type = type; + data = (char *)(long)((long)item + sizeof(*item)); + memcpy(data,str,n); + //printf("(%c) queueitem.%p itemdata.%p n.%d allocsize.%d\n",type,item,data,n,allocsize); + //portable_mutex_unlock(&MEMmutex); + return(data); +} + void iguana_initQ(queue_t *Q,char *name) { - char *tst,*str = "need to init each Q when single threaded"; + char *tst,*str = (char *)"need to init each Q when single threaded"; memset(Q,0,sizeof(*Q)); strcpy(Q->name,name); queue_enqueue(name,Q,queueitem(str),1);