Browse Source

Test

etomic
jl777 7 years ago
parent
commit
d70d5c835d
  1. 13
      iguana/exchanges/LP_utxo.c
  2. 1
      includes/cJSON.h

13
iguana/exchanges/LP_utxo.c

@ -31,16 +31,17 @@ struct cJSON_list
{ {
struct cJSON_list *next,*prev; struct cJSON_list *next,*prev;
cJSON *item; cJSON *item;
uint32_t timestamp; uint32_t timestamp,cjsonid;
} *LP_cJSONlist; } *LP_cJSONlist;
void cJSON_register(cJSON *item) void cJSON_register(cJSON *item)
{ {
struct cJSON_list *ptr; struct cJSON_list *ptr;
printf(" register %p\n",item);
ptr = calloc(1,sizeof(*ptr)); ptr = calloc(1,sizeof(*ptr));
ptr->timestamp = (uint32_t)time(NULL); ptr->timestamp = (uint32_t)time(NULL);
ptr->item = item; ptr->item = item;
item->cjsonid = rand();
ptr->cjsonid = item->cjsonid;
portable_mutex_lock(&LP_cJSONmutex); portable_mutex_lock(&LP_cJSONmutex);
DL_APPEND(LP_cJSONlist,ptr); DL_APPEND(LP_cJSONlist,ptr);
portable_mutex_unlock(&LP_cJSONmutex); portable_mutex_unlock(&LP_cJSONmutex);
@ -51,8 +52,7 @@ void cJSON_unregister(cJSON *item)
{ {
static uint32_t lasttime; static uint32_t lasttime;
char *tmpstr,str[65]; int32_t n; uint64_t total; struct cJSON_list *ptr,*tmp; char *tmpstr,str[65]; int32_t n; uint64_t total; struct cJSON_list *ptr,*tmp;
printf("unregister %p\n",item); //if ( time(NULL) > lasttime+6 )
if ( time(NULL) > lasttime+6 )
{ {
n = 0; n = 0;
total = 0; total = 0;
@ -68,18 +68,17 @@ void cJSON_unregister(cJSON *item)
} }
DL_FOREACH_SAFE(LP_cJSONlist,ptr,tmp) DL_FOREACH_SAFE(LP_cJSONlist,ptr,tmp)
{ {
if ( ptr->item == item ) if ( ptr->cjsonid == item->cjsonid )//ptr->item == item )
break; break;
ptr = 0; ptr = 0;
} }
if ( ptr != 0 ) if ( ptr != 0 )
{ {
printf("found %p\n",item);
portable_mutex_lock(&LP_cJSONmutex); portable_mutex_lock(&LP_cJSONmutex);
DL_DELETE(LP_cJSONlist,ptr); DL_DELETE(LP_cJSONlist,ptr);
free(ptr); free(ptr);
portable_mutex_unlock(&LP_cJSONmutex); portable_mutex_unlock(&LP_cJSONmutex);
} //else printf("cJSON_unregister of unknown %p\n",item); } else printf("cJSON_unregister of unknown %p\n",item);
} }
struct LP_inuse_info *_LP_inuse_find(bits256 txid,int32_t vout) struct LP_inuse_info *_LP_inuse_find(bits256 txid,int32_t vout)

1
includes/cJSON.h

@ -73,6 +73,7 @@ extern "C"
double valuedouble; /* The item's number, if type==cJSON_Number */ double valuedouble; /* The item's number, if type==cJSON_Number */
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
uint32_t cjsonid;
} cJSON; } cJSON;
typedef struct cJSON_Hooks { typedef struct cJSON_Hooks {

Loading…
Cancel
Save