Пример #1
0
/****************************************************************
Name: ag_alloc_flow_struct
Description: 
    allocates a flow structure. The purpose of this function is to give abstruction
    to the way the flow structre is allocated.
Parameters:
	AgFlow** p_flow:
        the parameter in which the allocated pointer will be returned.
Returns AgResult :
****************************************************************/
AgResult ag_alloc_flow_struct(AgFlow** p_flow)
{
	AgResult n_res;

	/*  Shabtay Alloc */
	n_res = agos_calloc(32,  (void **)p_flow);

#if 0
#ifdef AG_CLSB_RS120_ALLOC
	n_res = agos_alloc_buffer(&xAgGlobals.x_part.x_part32, (void **)p_flow);
#else
    if(sizeof(AgFlow) > 12)
    {
        /* a larger inheriting class did not implement the operator new */
        AGOS_SWERR(AGOS_SWERR_WARNING, "[mp handler]alloc_leaf: size= expected_size=", sizeof(AgFlow), 12 ,0,0,0);
		*p_flow = NULL;
        return AG_E_FAIL;
    }
	n_res = CAgClsMemMng::instance()->get_buf_pool12().allocate_buffer((void*&)*p_flow);
#endif
#endif
	if(AG_FAILED(n_res))
    {
		AGOS_SWERR(AGOS_SWERR_WARNING,"ag_alloc_flow_struct: allocation is failed n_res=",n_res,0,0,0,0);
    }
    else
    {
        nCurrFlowAlloc++;
#if defined AG_MEM_MONITOR
        nMaxFlowAlloc = ag_max(nCurrFlowAlloc,nMaxFlowAlloc);
#endif
    }
    return n_res;
}
Пример #2
0
/* Copy-pasted from above. Yes I know this is bad. One day I might even fix it. */
const char *boyer_moore_strncasestr(const char *s, const char *find, const size_t s_len, const size_t f_len,
                                    const size_t alpha_skip_lookup[], const size_t *find_skip_lookup) {
    ssize_t i;
    size_t pos = f_len - 1;

    while (pos < s_len) {
        for (i = f_len - 1; i >= 0 && tolower(s[pos]) == find[i]; pos--, i--) {
        }
        if (i < 0) {
            return s + pos + 1;
        }
        pos += ag_max(alpha_skip_lookup[(unsigned char)s[pos]], find_skip_lookup[i]);
    }

    return NULL;
}