Exemplo n.º 1
0
static PyObject* PyJudyIntSetIter_iternext(PyJudyIntSetIter* iter)
{
	JError_t JError;
	int i;

	if (iter->s->s == 0)
		return 0;

	if (iter->b == 0) {
		i = Judy1First(iter->s->s, &iter->i, &JError);
		iter->b = 1;													
																																																			
		if (i == JERR) {
			judy_set_error(&JError);
			return 0;
		}

		return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)iter->i);
	}

	i = Judy1Next(iter->s->s, &iter->i, &JError);

	if (i == JERR) {
		judy_set_error(&JError);
		return 0;
	}

	if (i == 0)
		return 0;

	return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)iter->i);
}
Exemplo n.º 2
0
unsigned long flx_collector_t::reap ()
{
  unsigned long count = 0;
  Word_t next=(Word_t)NULL;
  int res = Judy1First(j_tmp,&next,&je);
  while(res) {
    delete_frame((void *)(void*)next);
    ++count;
    res = Judy1Next(j_tmp,&next,&je);
  }
  Judy1FreeArray(&j_tmp,&je);
  if(debug) {
    fprintf(stderr,"Reaped %lu objects\n",count);
    fprintf(stderr,"Still allocated %lu objects occupying %lu bytes\n", get_allocation_count(), get_allocation_amt());
  }
  return count;
}
Exemplo n.º 3
0
int
Judy1Dup(PPvoid_t PPDest, Pvoid_t PSource, JError_t * PJError)
{
    Pvoid_t   newJArray = 0;            // new Judy1 array to ppopulate
    Word_t    kindex;                   // Key/index
    int       Ins_rv = 0;               // Insert return value

    for (kindex = 0L, Ins_rv = Judy1First(PSource, &kindex, PJError);
         Ins_rv == 1; Ins_rv = Judy1Next(PSource, &kindex, PJError))
    {
        Ins_rv = Judy1Set(&newJArray, kindex, PJError);
    }
    if (Ins_rv == JERR)
        return Ins_rv;

    *PPDest = newJArray;
    return Ins_rv;
}                                       /*  Judy1Dup */
Exemplo n.º 4
0
/*
 * decorated module cleanup (if judy active)
 */
int decorated_module_cleanup(void)
{
#ifdef _WAVE_HAVE_JUDY
if(GLOBALS->sym_tree)
	{
	JudySLFreeArray(&GLOBALS->sym_tree, PJE0);
	}

if(GLOBALS->sym_tree_addresses)
	{
	int rcValue;
	Word_t Index = 0;

	for (rcValue = Judy1First(GLOBALS->sym_tree_addresses, &Index, PJE0); rcValue != 0; rcValue = Judy1Next(GLOBALS->sym_tree_addresses, &Index, PJE0))
        	{
        	((struct tree *)Index)->children_in_gui = 0;
	        }

	Judy1FreeArray(&GLOBALS->sym_tree_addresses, PJE0);
	}

#endif
return(1);
}
Exemplo n.º 5
0
static PyObject* PyJudyIntSet_repr(PyJudyIntSet* set)
{
	if (!set->allow_print)
		return PyString_FromFormat("<%s object at %p>", Py_TYPE(set)->tp_name, (void*)set);

	char s_buffer[32];
	PyObject* retval = 0;
	PyObject* comma_space = 0;
	PyObject* s = 0;

	if (set->s == 0)
		return PyString_FromString("JudyIntSet([])");

	if ((comma_space = PyString_FromString(", ")) == 0)
		goto cleanup;

	retval = PyString_FromString("JudyIntSet([");

	if (retval == 0)
		goto cleanup;

	JError_t JError;
	Word_t v = 0;
	Judy1First(set->s, &v, &JError);

	sprintf(s_buffer, "%llu", (unsigned long long)v);
	s = PyString_FromString(s_buffer);

	if (s == 0) {
		Py_CLEAR(retval);
		goto cleanup;
	}

	PyString_ConcatAndDel(&retval, s);

	if (retval == 0)
		goto cleanup;

	while (1) {
		int i = Judy1Next(set->s, &v, &JError);

		if (i == 0)
			break;

		PyString_Concat(&retval, comma_space);

		if (retval == 0)
			goto cleanup;

		sprintf(s_buffer, "%llu", (unsigned long long)v);
		s = PyString_FromString(s_buffer);

		if (s == 0) {
			Py_CLEAR(retval);
			goto cleanup;
		}

		PyString_ConcatAndDel(&retval, s);

		if (retval == 0)
			goto cleanup;
	}

	s = PyString_FromString("])");

	if (s == 0)
		goto cleanup;

	PyString_ConcatAndDel(&retval, s);

cleanup:

	Py_XDECREF(comma_space);

	return retval;
}
Exemplo n.º 6
0
int ugh_client_send(ugh_client_t *c, int status)
{
#if 0
	if (0 == c->content_type.size)
	{
		c->content_type.size = sizeof("text/plain") - 1;
		c->content_type.data = "text/plain";
	}
#endif

	size_t i;

	for (i = 0; i < ugh_module_handles_size; ++i)
	{
		c->bufs_sumlen += c->bufs[i].size;
	}

	c->buf_send.data = (char *) aux_pool_nalloc(c->pool, UGH_HEADER_BUF);
	c->buf_send.size = snprintf(c->buf_send.data, UGH_HEADER_BUF,
		"HTTP/1.1 %s"              CRLF
		"Server: ugh/"UGH_VERSION  CRLF
		"Content-Length: %"PRIuMAX CRLF
		"Connection: close"        CRLF
		/* "Content-Type: %.*s"       CRLF */
		, ugh_status_header[status]
		, (uintmax_t) c->bufs_sumlen
		/* , (int) c->content_type.size, c->content_type.data */
	);

	void **vptr;
	Word_t idx = 0;

	for (vptr = JudyLFirst(c->headers_out_hash, &idx, PJE0); vptr; vptr = JudyLNext(c->headers_out_hash, &idx, PJE0))
	{
		ugh_header_t *h = *vptr;

		c->buf_send.size += snprintf(c->buf_send.data + c->buf_send.size, UGH_HEADER_BUF - c->buf_send.size,
			"%.*s: %.*s" CRLF, (int) h->key.size, h->key.data, (int) h->value.size, h->value.data);
	}

#if 0
	if (0 != c->location.size)
	{
		c->buf_send.size += snprintf(c->buf_send.data + c->buf_send.size, UGH_HEADER_BUF - c->buf_send.size,
			"Location: %.*s" CRLF, (int) c->location.size, c->location.data);
	}
#endif

	int rc;
	idx = 0;

	for (rc = Judy1First(c->cookies_out_hash, &idx, PJE0); rc; rc = Judy1Next(c->cookies_out_hash, &idx, PJE0))
	{
		strp cookie = (strp) idx;

		c->buf_send.size += snprintf(c->buf_send.data + c->buf_send.size, UGH_HEADER_BUF - c->buf_send.size,
			"Set-Cookie: %.*s" CRLF, (int) cookie->size, cookie->data);
	}

	c->buf_send.size += snprintf(c->buf_send.data + c->buf_send.size, UGH_HEADER_BUF - c->buf_send.size, CRLF);

	log_notice("access %s:%u '%.*s%s%.*s' %.*s %"PRIuMAX, inet_ntoa(c->addr.sin_addr), ntohs(c->addr.sin_port), (int) c->uri.size, c->uri.data,
		c->args.size ? "?" : "", (int) c->args.size, c->args.data, 3, ugh_status_header[status],
		(uintmax_t) c->bufs_sumlen);

	ev_io_start(loop, &c->wev_send);

	return 0;
}
Exemplo n.º 7
0
 void operator++ ()
 {
     if (0 == Judy1Next(m_Array, &m_Index, PJE0))
         m_End = true;
 }