本文整理汇总了C++中rfree函数的典型用法代码示例。如果您正苦于以下问题:C++ rfree函数的具体用法?C++ rfree怎么用?C++ rfree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rfree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rfree
void rfree(void* x) {
if ((x != NIL) &&
(x != TRUE) &&
(x != FALSE) &&
(x != NULL)) {
switch(type(x)) {
case SPECIAL:
/* can't be freed */
return;
case FUNCTION:
/* TODO */
return;
case INT:
/* no members to free */
break;
case SYMBOL:
free(SVAL(x));
break;
case CONS:
rfree(CAR(x));
rfree(CDR(x));
break;
}
free(x);
}
}
示例2: SpaceNotStable
const Choice*
Space::choice(void) {
if (!stable())
throw SpaceNotStable("Space::choice");
if (failed() || (b_status == Brancher::cast(&bl))) {
// There are no more choices to be generated
// Delete all branchers
Brancher* b = Brancher::cast(bl.next());
while (b != Brancher::cast(&bl)) {
Brancher* d = b;
b = Brancher::cast(b->next());
rfree(d,d->dispose(*this));
}
bl.init();
b_status = b_commit = Brancher::cast(&bl);
return NULL;
}
/*
* The call to choice() says that no older choices
* can be used. Hence, all branchers that are exhausted can be deleted.
*/
Brancher* b = Brancher::cast(bl.next());
while (b != b_status) {
Brancher* d = b;
b = Brancher::cast(b->next());
d->unlink();
rfree(d,d->dispose(*this));
}
// Make sure that b_commit does not point to a deleted brancher!
b_commit = b_status;
return b_status->choice(*this);
}
示例3: selector_free
/**
* \brief Frees selector component.
* \param[in,out] dev Selector base component device.
*/
static void selector_free(struct comp_dev *dev)
{
struct comp_data *cd = comp_get_drvdata(dev);
trace_selector("selector_free()");
rfree(cd);
rfree(dev);
}
示例4: test_keyword_free
static void test_keyword_free(struct comp_dev *dev)
{
struct comp_data *cd = comp_get_drvdata(dev);
trace_keyword("test_keyword_free()");
free_mem_load(cd);
rfree(cd);
rfree(dev);
}
示例5: rpmfcAttrFree
static rpmfcAttr rpmfcAttrFree(rpmfcAttr attr)
{
if (attr) {
ruleFree(&attr->incl);
ruleFree(&attr->excl);
rfree(attr->name);
rfree(attr);
}
return NULL;
}
示例6: DialogProc
BOOL DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
{
SelectObject(g_hdc, g_hbmpOld);
DeleteObject(g_hbmp);
DeleteDC(g_hdc);
EndDialog(hDlg, 0);
break;
}
case WM_INITDIALOG:
{
int i;
t_region *region, *rgnExclude = NULL, *rgnNew;
g_hdc = CreateCompatibleDC(NULL);
g_hbmp = CreateCompatibleBitmap(GetDC(NULL), 640, 480);
g_hbmpOld = SelectObject(g_hdc, g_hbmp);
region = create_rect_region(g_rcInclude.left, g_rcInclude.top, g_rcInclude.right, g_rcInclude.bottom);
for (i=0;i<EXCLUDES;i++)
rgnExclude = append_regions(rgnExclude, create_rect_region(g_rcExclude[i].left, g_rcExclude[i].top, g_rcExclude[i].right, g_rcExclude[i].bottom));
rgnNew = difference_regions(region, rgnExclude);
rfree(®ion);
rfree(&rgnExclude);
region = rgnNew;
while (region)
{
Rectangle(g_hdc, region->rcRegion.left, region->rcRegion.top, region->rcRegion.right, region->rcRegion.bottom);
region = region->next;
}
rfree(&rgnNew);
SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)"Region Test");
break;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hDlg, &ps);
BitBlt(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top, g_hdc, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);
EndPaint(hDlg, &ps);
break;
}
default:
return FALSE;
}
return TRUE;
}
示例7: ferite_classic_free
void ferite_classic_free( void *targetptr, char *file, int line, FeriteScript *script )
{
#ifdef FERITE_MEM_DEBUG
struct ferite_memory_block *ptr, *temp_ptr;
if( targetptr == NULL )
printf( "Trying to free NULL ptr on %s:%d\n", file, line );
LOCK_MEMORY;
for( ptr = mem_rootblk; ptr->next != NULL; ptr = ptr->next )
{
if( ptr->next->data == targetptr )
{
# ifdef SUPER_VERBOSE
FUD(("INFO: Found memory block (%p). Freeing.\n", ptr->next->data));
# endif
ferite_classic_free_count++;
temp_ptr = ptr->next;
ptr->next = temp_ptr->next;
# ifdef SUPER_VERBOSE
FUD(("INFO: Freeing %p\n", temp_ptr->data ));
# endif
rfree( temp_ptr->data );
# ifdef SUPER_VERBOSE
FUD((" * Free'd data\n"));
# endif
free( temp_ptr->file );
# ifdef SUPER_VERBOSE
FUD((" * Free'd filename\n"));
# endif
free( temp_ptr );
# ifdef SUPER_VERBOSE
FUD((" * Free'd memory block\n"));
# endif
UNLOCK_MEMORY;
return;
}
}
FUD(("* URGH. Can't find block(%p) in memory list. Freeing Anyways.\n", targetptr));
free( targetptr );
UNLOCK_MEMORY;
#else
LOCK_MEMORY;
if( targetptr == NULL )
printf( "Trying to free null in %s at %d\n", file, line );
else
ferite_classic_free_count++;
rfree( targetptr );
UNLOCK_MEMORY;
#endif
}
示例8: trace_selector
/**
* \brief Creates selector component.
* \param[in,out] data Selector base component device.
* \return Pointer to selector base component device.
*/
static struct comp_dev *selector_new(struct sof_ipc_comp *comp)
{
struct sof_ipc_comp_process *ipc_process =
(struct sof_ipc_comp_process *)comp;
size_t bs = ipc_process->size;
struct comp_dev *dev;
struct comp_data *cd;
int ret;
trace_selector("selector_new()");
if (IPC_IS_SIZE_INVALID(ipc_process->config)) {
IPC_SIZE_ERROR_TRACE(TRACE_CLASS_SELECTOR, ipc_process->config);
return NULL;
}
dev = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
assert(!memcpy_s(&dev->comp, sizeof(struct sof_ipc_comp_process), comp,
sizeof(struct sof_ipc_comp_process)));
cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (!cd) {
rfree(dev);
return NULL;
}
comp_set_drvdata(dev, cd);
assert(!memcpy_s(&cd->config, sizeof(cd->config), ipc_process->data,
bs));
/* verification of initial parameters */
ret = sel_set_channel_values(cd, cd->config.in_channels_count,
cd->config.out_channels_count,
cd->config.sel_channel);
if (ret < 0) {
rfree(cd);
rfree(dev);
return NULL;
}
dev->state = COMP_STATE_READY;
return dev;
}
示例9: chsnbrg_simtr
/**
@brief 密行列AをHessenberg型行列Bに相似変換する.
@param[in] n 正方行列A,Bのサイズ
@param[in] A 行列
@param[in] LDA Aの第1次元
@param[out] B 相似変換により得られたHessenberg型行列
@param[in] LDB Bの第1次元
*/
void chsnbrg_simtr(int n, cmulti **B, int LDB, cmulti **A, int LDA)
{
int i,prec=53;
rmulti *alpha=NULL;
cmulti **h=NULL;
// allocate
prec=cmat_get_prec_max(n,n,B,LDB);
alpha=rallocate_prec(prec);
h=cvec_allocate_prec(n,prec);
// copy
cmat_copy(n,n,B,LDB,A,LDA);
// compute
for(i=0; i<n-2; i++){
// Householder vector
chouseholder_vec(n,i+1,h,alpha,&COL(B,i,LDB));
// similarity transformation
chouseholder_right(n,n,B,LDB,B,LDB,i+1,h,alpha);
chouseholder_left(n,n,B,LDB,B,LDB,i+1,h,alpha);
// set lower part as zeros
cvec_set_zeros(n-2-i,&MAT(B,i+2,i,LDB));
}
// done
alpha=rfree(alpha);
h=cvec_free(n,h);
}
示例10: bgp_close
/**
* bgp_close - close a BGP instance
* @p: BGP instance
* @apply_md5: 0 to disable unsetting MD5 auth
*
* This function frees and deconfigures shared BGP resources.
* @apply_md5 is set to 0 when bgp_close is called as a cleanup
* from failed bgp_open().
*/
static void
bgp_close(struct bgp_proto *p, int apply_md5)
{
ASSERT(bgp_counter);
bgp_counter--;
if (p->cf->password && apply_md5)
sk_set_md5_auth(bgp_listen_sk, p->cf->remote_ip, p->cf->iface, NULL);
if (!bgp_counter)
{
rfree(bgp_listen_sk);
bgp_listen_sk = NULL;
rfree(bgp_linpool);
bgp_linpool = NULL;
}
}
示例11: rhouseholder_vec
/**
@brief ハウスホルダー・ベクトルへの変換.
@details h[0]=0; ...; h[k-1]=0; h[k]=-s*xi; h[k+1]=x[k+1]; ...; h[n-1]=x[n-1];
@param[in] h 初期化済みのベクトル.サイズはn.
@param[in] x 初期化済みのベクトル.サイズはn.
@param[in] n ベクトルのサイズ.
@param[in] k 第k要素が基準.
@param[out] h ハウスホルダー・ベクトル.
*/
void rhouseholder_vec(int n, int k, rmulti **h, rmulti *alpha, rmulti **x)
{
int p0,p1,prec;
rmulti *eta=NULL,*zeta=NULL,*xi=NULL,*axk=NULL;
// allocate
p0=rget_prec(alpha);
p1=rvec_get_prec_max(n,h);
prec=MAX2(p0,p1);
eta=rallocate_prec(prec);
zeta=rallocate_prec(prec);
xi=rallocate_prec(prec);
axk=rallocate_prec(prec);
//----------- norm
rvec_sum_pow2(xi,n-k-1,&x[k+1]); // xi=sum(abs(x((k+1):end)).^2);
rmul(axk,x[k],x[k]); // axk=|x[k]|^2
radd(eta,axk,xi); // eta=|x[k]|^2+...
rsqrt(axk,axk); // axk=|x[k]|
rsqrt(eta,eta); // eta=sqrt(|x[k]|^2+...)
if(req_d(eta,0)){rsub(xi,eta,axk);} // xi=eta-|x(k)|
else{ // xi=xi/(|x(k)|+eta)
radd(zeta,axk,eta);
rdiv(xi,xi,zeta);
}
//----------- h
rvec_set_zeros(k,h);
rvec_copy(n-k-1,&h[k+1],&x[k+1]); // h((k+1):end)=x((k+1):end);
if(ris_zero(x[k])){
rcopy(h[k],xi); rneg(h[k],h[k]); // h[k]=-xi
}else{
rdiv(zeta,xi,axk); rneg(zeta,zeta); // zeta=-xi/axk;
rmul(h[k],x[k],zeta); // h[k]=zeta*x[k];
}
//----------- alpha
if(req_d(xi,0) || req_d(eta,0)){
rset_d(alpha,0);
}else{
rmul(alpha,xi,eta); // alpha=1/(xi*eta)
rinv(alpha,alpha);
}
// free
eta=rfree(eta);
zeta=rfree(zeta);
xi=rfree(xi);
axk=rfree(axk);
}
示例12: bgp_close_conn
/**
* bgp_close_conn - close a BGP connection
* @conn: connection to close
*
* This function takes a connection described by the &bgp_conn structure,
* closes its socket and frees all resources associated with it.
*/
void
bgp_close_conn(struct bgp_conn *conn)
{
// struct bgp_proto *p = conn->bgp;
DBG("BGP: Closing connection\n");
conn->packets_to_send = 0;
rfree(conn->connect_retry_timer);
conn->connect_retry_timer = NULL;
rfree(conn->keepalive_timer);
conn->keepalive_timer = NULL;
rfree(conn->hold_timer);
conn->hold_timer = NULL;
rfree(conn->sk);
conn->sk = NULL;
rfree(conn->tx_ev);
conn->tx_ev = NULL;
}
示例13: TestSingleMatch
static int TestSingleMatch()
{
regex* re = regex_create("a", NULL);
program* prog = &(re->prog);
mu_assert("program length", prog->size == 2);
mu_assert("first inst is rule", prog->code[0].op == I_CHAR);
mu_assert("second inst is match", prog->code[1].op == I_MATCH);
rfree(re);
return 1;
}
示例14: EvalCcRqGETFONTSIZES
void EvalCcRqGETFONTSIZES (CrossCallInfo *pcci) // textptr; no result.
{
HDC hdc;
hdc = GetDC (ghMainWindow);
EnumFontFamilies (hdc, (char *) pcci->p1, (FONTENUMPROC) EnumFontSizeProc, 0);
ReleaseDC (ghMainWindow, hdc);
rfree ((char *) pcci->p1);
MakeReturn0Cci (pcci);
}
示例15: TestConcat
static int TestConcat()
{
regex* re = regex_create("ab", NULL);
program* prog = &(re->prog);
mu_assert("program length", prog->size == 3);
mu_assert("first inst is split", prog->code[0].op == I_CHAR);
mu_assert("second inst is rule", prog->code[1].op == I_CHAR);
mu_assert("third inst is match", prog->code[2].op == I_MATCH);
rfree(re);
return 1;
}