本文整理汇总了C++中MyFree函数的典型用法代码示例。如果您正苦于以下问题:C++ MyFree函数的具体用法?C++ MyFree怎么用?C++ MyFree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MyFree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: del_msg_element
/** Remove a message from the lookup trie.
* @param[in,out] mtree_p Trie node to remove command from.
* @param[in] cmd Text of command to remove.
*/
struct MessageTree *
del_msg_element(struct MessageTree *mtree_p, char *cmd)
{
int slot = *cmd & (MAXPTRLEN-1);
/* Either remove leaf message or from appropriate child. */
if (*cmd == '\0')
mtree_p->msg = NULL;
else
mtree_p->pointers[slot] = del_msg_element(mtree_p->pointers[slot], cmd + 1);
/* If current message or any child still exists, keep this node. */
if (mtree_p->msg)
return mtree_p;
for (slot = 0; slot < MAXPTRLEN; ++slot)
if (mtree_p->pointers[slot])
return mtree_p;
/* Otherwise, if we're not a root node, free it and return null. */
if (mtree_p != &msg_tree && mtree_p != &tok_tree)
MyFree(mtree_p);
return NULL;
}
示例2: auth_timeout_callback
/*
* auth_timeout - timeout a given auth request
*/
static void auth_timeout_callback(struct Event* ev)
{
struct AuthRequest* auth;
assert(0 != ev_timer(ev));
assert(0 != t_data(ev_timer(ev)));
auth = t_data(ev_timer(ev));
if (ev_type(ev) == ET_DESTROY) { /* being destroyed */
auth->flags &= ~AM_TIMEOUT;
if (!(auth->flags & AM_FREE_MASK)) {
Debug((DEBUG_LIST, "Freeing auth from timeout callback; %p [%p]", auth,
ev_timer(ev)));
MyFree(auth); /* done with it, finally */
}
} else {
assert(ev_type(ev) == ET_EXPIRE);
destroy_auth_request(auth, 1);
}
}
示例3: uping_killer_callback
/** Timer callback to stop upings.
* @param[in] ev Event for uping expiration.
*/
static void uping_killer_callback(struct Event* ev)
{
struct UPing *pptr;
assert(0 != ev_timer(ev));
assert(0 != t_data(ev_timer(ev)));
pptr = (struct UPing*) t_data(ev_timer(ev));
Debug((DEBUG_SEND, "uping_killer_callback called, %p (%d)", pptr,
ev_type(ev)));
if (ev_type(ev) == ET_DESTROY) { /* being destroyed */
pptr->freeable &= ~UPING_PENDING_KILLER;
if (!pptr->freeable)
MyFree(pptr); /* done with it, finally */
} else {
assert(ev_type(ev) == ET_EXPIRE);
uping_end(pptr); /* <FUDD>kill the uping, kill the uping!</FUDD> */
}
}
示例4: uping_read_callback
/** Callback for socket activity on an outbound uping socket.
* @param[in] ev I/O event for socket.
*/
static void uping_read_callback(struct Event* ev)
{
struct UPing *pptr;
assert(0 != ev_socket(ev));
assert(0 != s_data(ev_socket(ev)));
pptr = (struct UPing*) s_data(ev_socket(ev));
Debug((DEBUG_SEND, "uping_read_callback called, %p (%d)", pptr,
ev_type(ev)));
if (ev_type(ev) == ET_DESTROY) { /* being destroyed */
pptr->freeable &= ~UPING_PENDING_SOCKET;
if (!pptr->freeable)
MyFree(pptr); /* done with it, finally */
} else {
assert(ev_type(ev) == ET_READ || ev_type(ev) == ET_ERROR);
uping_read(pptr); /* read uping response */
}
}
示例5: CompleteTransaction
/****************************************************************************
* *
* FUNCTION : CompleteTransaction() *
* *
* PURPOSE : This handles completed synchronous and asynchronous *
* transactions as well as failed attempted transactions. *
* *
* RETURNS : TRUE - If successful. *
* FALSE - otherwise. *
* *
****************************************************************************/
VOID CompleteTransaction(
HWND hwndInfoCtrl,
XACT *pxact)
{
PSTR psz;
if (pxact->ret) {
/*
* Successful transaction case
*/
SendMessage(hwndInfoCtrl, ICM_SETSTRING, ICSID_LL,
(DWORD)(LPSTR)"Completed");
if (pxact->wType == XTYP_REQUEST) {
/*
* Show resulting data
*/
psz = GetTextData((HDDEDATA)pxact->ret);
SendMessage(hwndInfoCtrl, ICM_SETSTRING, ICSID_CENTER,
(DWORD)(LPSTR)psz);
MyFree(psz);
/*
* free returned data since it is displayed.
*/
DdeFreeDataHandle(pxact->ret);
pxact->ret = 0L;
SendMessage(hwndInfoCtrl, ICM_SETSTRING, ICSID_UR, NULL);
}
} else {
/*
* failed - show error result.
*/
SendMessage(hwndInfoCtrl, ICM_SETSTRING, ICSID_LL,
(DWORD)(LPSTR)Error2String(DdeGetLastError(idInst)));
}
pxact->fsOptions |= XOPT_COMPLETED;
}
示例6: init_finish
static int init_finish(adns_state ads) {
struct in_addr ia;
int r;
if (!ads->nservers) {
if (ads->diagfile && ads->iflags & adns_if_debug)
fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
ia.s_addr= htonl(INADDR_LOOPBACK);
addserver(ads,ia);
}
ads->udpsocket= socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if (ads->udpsocket<0) { r= errno; goto x_free; }
r= adns__setnonblock(ads,ads->udpsocket);
if (r) { r= errno; goto x_closeudp; }
return 0;
x_closeudp:
close(ads->udpsocket);
x_free:
MyFree(ads);
return r;
}
示例7: MyZMalloc
void EDA_LibComponentStruct::SortDrawItems(void)
/*******************************************/
/* Trie les éléments graphiques d'un composant lib pour améliorer
le tracé:
items remplis en premier, pins en dernier
En cas de superposition d'items, c'est plus lisible
*/
{
LibEDA_BaseStruct ** Bufentry, ** BufentryBase, *Entry = m_Drawings;
int ii, nbitems;
if(Entry == NULL ) return; /* Pas d'alias pour ce composant */
/* calcul du nombre d'items */
for( nbitems = 0; Entry != NULL; Entry = Entry->Next()) nbitems++;
BufentryBase =
(LibEDA_BaseStruct **) MyZMalloc( (nbitems+1) * sizeof(LibEDA_BaseStruct *));
/* memorisation du chainage : */
for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next())
BufentryBase[ii++] = Entry;
/* Tri du chainage */
qsort(BufentryBase, nbitems, sizeof(LibEDA_BaseStruct *), SortItemsFct);
/* Mise a jour du chainage. Remarque:
le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/
m_Drawings = * BufentryBase;
Bufentry = BufentryBase;
for (ii = 0 ; ii < nbitems; ii++)
{
(* Bufentry)->Pnext = * (Bufentry+1);
Bufentry++;
}
MyFree(BufentryBase);
}
示例8: throw
CDynLimBuf &CDynLimBuf::operator+=(const char *s) throw()
{
if (_error)
return *this;
unsigned len = MyStringLen(s);
size_t rem = _sizeLimit - _pos;
if (rem < len)
{
len = (unsigned)rem;
_error = true;
}
if (_size - _pos < len)
{
size_t n = _pos + len;
if (n - _size < _size)
{
n = _sizeLimit;
if (n - _size > _size)
n = _size * 2;
}
Byte *newBuf = (Byte *)MyAlloc(n);
if (!newBuf)
{
_error = true;
return *this;
}
memcpy(newBuf, _chars, _pos);
MyFree(_chars);
_chars = newBuf;
_size = n;
}
memcpy(_chars + _pos, s, len);
_pos += len;
return *this;
}
示例9: UmodeDel
void UmodeDel(Umode *umode)
{
if (loop.ircd_rehashing)
umode->unloaded = 1;
else
{
aClient *cptr;
for (cptr = client; cptr; cptr = cptr->next)
{
long oldumode = 0;
if (!IsPerson(cptr))
continue;
oldumode = cptr->umodes;
cptr->umodes &= ~umode->mode;
if (MyClient(cptr))
send_umode_out(cptr, cptr, oldumode);
}
umode->flag = '\0';
AllUmodes &= ~(umode->mode);
SendUmodes &= ~(umode->mode);
make_umodestr();
}
if (umode->owner) {
ModuleObject *umodeobj;
for (umodeobj = umode->owner->objects; umodeobj; umodeobj = umodeobj->next) {
if (umodeobj->type == MOBJ_UMODE && umodeobj->object.umode == umode) {
DelListItem(umodeobj, umode->owner->objects);
MyFree(umodeobj);
break;
}
}
umode->owner = NULL;
}
return;
}
示例10: Lzma86_Encode
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
int level, UInt32 dictSize, int filterMode)
{
ISzAlloc g_Alloc = { SzAlloc, SzFree };
size_t outSize2 = *destLen;
Byte *filteredStream;
Bool useFilter;
int mainResult = SZ_ERROR_OUTPUT_EOF;
CLzmaEncProps props;
LzmaEncProps_Init(&props);
props.level = level;
props.dictSize = dictSize;
*destLen = 0;
if (outSize2 < LZMA86_HEADER_SIZE)
return SZ_ERROR_OUTPUT_EOF;
{
int i;
UInt64 t = srcLen;
for (i = 0; i < 8; i++, t >>= 8)
dest[LZMA86_SIZE_OFFSET + i] = (Byte)t;
}
filteredStream = 0;
useFilter = (filterMode != SZ_FILTER_NO);
if (useFilter)
{
if (srcLen != 0)
{
filteredStream = (Byte *)MyAlloc(srcLen);
if (filteredStream == 0)
return SZ_ERROR_MEM;
memcpy(filteredStream, src, srcLen);
}
{
UInt32 x86State;
x86_Convert_Init(x86State);
x86_Convert(filteredStream, srcLen, 0, &x86State, 1);
}
}
{
size_t minSize = 0;
Bool bestIsFiltered = False;
/* passes for SZ_FILTER_AUTO:
0 - BCJ + LZMA
1 - LZMA
2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better.
*/
int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;
int i;
for (i = 0; i < numPasses; i++)
{
size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE;
size_t outPropsSize = 5;
SRes curRes;
Bool curModeIsFiltered = (numPasses > 1 && i == numPasses - 1);
if (curModeIsFiltered && !bestIsFiltered)
break;
if (useFilter && i == 0)
curModeIsFiltered = True;
curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed,
curModeIsFiltered ? filteredStream : src, srcLen,
&props, dest + 1, &outPropsSize, 0,
NULL, &g_Alloc, &g_Alloc);
if (curRes != SZ_ERROR_OUTPUT_EOF)
{
if (curRes != SZ_OK)
{
mainResult = curRes;
break;
}
if (outSizeProcessed <= minSize || mainResult != SZ_OK)
{
minSize = outSizeProcessed;
bestIsFiltered = curModeIsFiltered;
mainResult = SZ_OK;
}
}
}
dest[0] = (Byte)(bestIsFiltered ? 1 : 0);
*destLen = LZMA86_HEADER_SIZE + minSize;
}
if (useFilter)
MyFree(filteredStream);
return mainResult;
}
示例11: CMD_FUNC
//.........这里部分代码省略.........
*/
sptr->nospoof = getrandom32();
if (PINGPONG_WARNING)
sendto_one(sptr, ":%s NOTICE %s :*** If you are having problems"
" connecting due to ping timeouts, please"
" type /quote pong %X or /raw pong %X now.",
me.name, nick, sptr->nospoof, sptr->nospoof);
sendto_one(sptr, "PING :%X", sptr->nospoof);
#endif /* NOSPOOF */
#ifdef CONTACT_EMAIL
sendto_one(sptr,
":%s NOTICE %s :*** If you need assistance with a"
" connection problem, please email " CONTACT_EMAIL
" with the name and version of the client you are"
" using, and the server you tried to connect to: %s",
me.name, nick, me.name);
#endif /* CONTACT_EMAIL */
#ifdef CONTACT_URL
sendto_one(sptr,
":%s NOTICE %s :*** If you need assistance with"
" connecting to this server, %s, please refer to: "
CONTACT_URL, me.name, nick, me.name);
#endif /* CONTACT_URL */
/* Copy password to the passwd field if it's given after NICK
* - originally by taz, modified by Wizzu
*/
if ((parc > 2) && (strlen(parv[2]) <= PASSWDLEN)
&& !(sptr->listener->umodes & LISTENER_JAVACLIENT))
{
if (sptr->passwd)
MyFree(sptr->passwd);
sptr->passwd = MyMalloc(strlen(parv[2]) + 1);
(void)strcpy(sptr->passwd, parv[2]);
}
/* This had to be copied here to avoid problems.. */
(void)strcpy(sptr->name, nick);
if (sptr->user && IsNotSpoof(sptr))
{
/*
** USER already received, now we have NICK.
** *NOTE* For servers "NICK" *must* precede the
** user message (giving USER before NICK is possible
** only for local client connection!). register_user
** may reject the client and call exit_client for it
** --must test this and exit m_nick too!!!
*/
#ifndef NOSPOOF
if (USE_BAN_VERSION && MyConnect(sptr))
sendto_one(sptr, ":[email protected]%s PRIVMSG %s :\1VERSION\1",
me.name, nick);
#endif
sptr->lastnick = TStime(); /* Always local client */
if (register_user(cptr, sptr, nick,
sptr->user->username, NULL, NULL, NULL) == FLUSH_BUFFER)
return FLUSH_BUFFER;
strcpy(nick, sptr->name); /* don't ask, but I need this. do not remove! -- Syzop */
update_watch = 0;
newusr = 1;
}
}
/*
* Finally set new nick name.
*/
示例12: m_challenge
/*
* m_challenge - generate RSA challenge for wouldbe oper
* parv[0] = sender prefix
* parv[1] = operator to challenge for, or +response
*
*/
static void
m_challenge(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
char *challenge;
dlink_node *ptr;
struct ConfItem *aconf, *oconf;
if(!(source_p->user) || !source_p->localClient)
return;
/* if theyre an oper, reprint oper motd and ignore */
if(IsOper(source_p))
{
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, parv[0]);
SendMessageFile(source_p, &ConfigFileEntry.opermotd);
return;
}
if(*parv[1] == '+')
{
/* Ignore it if we aren't expecting this... -A1kmm */
if(!source_p->user->response)
return;
if(irccmp(source_p->user->response, ++parv[1]))
{
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
log_foper(source_p, source_p->user->auth_oper);
if(ConfigFileEntry.failed_oper_notice)
sendto_realops_flags(UMODE_ALL, L_ALL,
"Failed OPER attempt by %s (%[email protected]%s)",
source_p->name, source_p->username,
source_p->host);
return;
}
if((aconf = find_conf_by_name(source_p->user->auth_oper, CONF_OPERATOR)) == NULL)
{
sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
log_foper(source_p, source_p->user->auth_oper);
if(ConfigFileEntry.failed_oper_notice)
sendto_realops_flags(UMODE_ALL, L_ALL,
"Failed CHALLENGE attempt - host mismatch by %s (%[email protected]%s)",
source_p->name, source_p->username,
source_p->host);
return;
}
ptr = source_p->localClient->confs.head;
oconf = ptr->data;
detach_conf(source_p, oconf);
if(attach_conf(source_p, aconf) != 0)
{
sendto_one(source_p, ":%s NOTICE %s :Can't attach conf!",
me.name, source_p->name);
sendto_realops_flags(UMODE_ALL, L_ALL,
"Failed CHALLENGE attempt by %s (%[email protected]%s) can't attach conf!",
source_p->name, source_p->username, source_p->host);
log_foper(source_p, source_p->user->auth_oper);
attach_conf(source_p, oconf);
return;
}
oper_up(source_p, aconf);
ilog(L_TRACE, "OPER %s by %s!%[email protected]%s",
source_p->user->auth_oper, source_p->name, source_p->username, source_p->host);
log_oper(source_p, source_p->user->auth_oper);
MyFree(source_p->user->response);
MyFree(source_p->user->auth_oper);
source_p->user->response = NULL;
source_p->user->auth_oper = NULL;
return;
}
MyFree(source_p->user->response);
MyFree(source_p->user->auth_oper);
source_p->user->response = NULL;
source_p->user->auth_oper = NULL;
if(!(aconf = find_conf_exact(parv[1], source_p->username, source_p->host,
CONF_OPERATOR)) &&
!(aconf = find_conf_exact(parv[1], source_p->username,
source_p->localClient->sockhost, CONF_OPERATOR)))
{
sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
log_foper(source_p, parv[1]);
if(ConfigFileEntry.failed_oper_notice)
sendto_realops_flags(UMODE_ALL, L_ALL,
//.........这里部分代码省略.........
示例13: SzFree
static void SzFree(void *, void *address) { MyFree(address); }
示例14: m_challenge
/*
* m_challenge - generate RSA challenge for wouldbe oper
* parv[0] = sender prefix
* parv[1] = operator to challenge for, or +response
*
*/
static void
m_challenge(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
char *challenge = NULL;
struct ConfItem *conf = NULL;
struct AccessItem *aconf = NULL;
/* if theyre an oper, reprint oper motd and ignore */
if(IsOper(source_p))
{
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, parv[0]);
send_message_file(source_p, &ConfigFileEntry.opermotd);
return;
}
if(*parv[1] == '+')
{
/* Ignore it if we aren't expecting this... -A1kmm */
if(source_p->localClient->response == NULL)
return;
if(svsnoop)
{
sendto_one(source_p,
":%s NOTICE %s :*** This server is in NOOP mode, you cannot /oper",
me.name, source_p->name);
failed_challenge_notice(source_p, source_p->localClient->auth_oper,
"This server is in NOOP mode");
log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n",
source_p->localClient->auth_oper);
return;
}
if(irccmp(source_p->localClient->response, ++parv[1]))
{
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
failed_challenge_notice(source_p, source_p->localClient->auth_oper,
"challenge failed");
return;
}
conf = find_exact_name_conf(OPER_TYPE,
source_p->localClient->auth_oper,
source_p->username, source_p->host);
if(conf == NULL)
conf = find_exact_name_conf(OPER_TYPE,
source_p->localClient->auth_oper,
source_p->username, source_p->realhost);
if(conf == NULL)
conf = find_exact_name_conf(OPER_TYPE,
source_p->localClient->auth_oper,
source_p->username, source_p->sockhost);
if(conf == NULL)
{
sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n",
source_p->localClient->auth_oper);
return;
}
if(attach_conf(source_p, conf) != 0)
{
sendto_one(source_p, ":%s NOTICE %s :Can't attach conf!",
me.name, source_p->name);
failed_challenge_notice(source_p, conf->name, "can't attach conf!");
log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n",
source_p->localClient->auth_oper);
return;
}
oper_up(source_p);
ilog(L_TRACE, "OPER %s by %s!%[email protected]%s",
source_p->localClient->auth_oper, source_p->name, source_p->username,
source_p->realhost);
log_oper_action(LOG_OPER_TYPE, source_p, "%s\n", source_p->localClient->auth_oper);
MyFree(source_p->localClient->response);
MyFree(source_p->localClient->auth_oper);
source_p->localClient->response = NULL;
source_p->localClient->auth_oper = NULL;
return;
}
MyFree(source_p->localClient->response);
MyFree(source_p->localClient->auth_oper);
source_p->localClient->response = NULL;
source_p->localClient->auth_oper = NULL;
if((conf = find_conf_exact(OPER_TYPE, parv[1], source_p->username, source_p->host)) != NULL)
aconf = map_to_conf(conf);
else if((conf = find_conf_exact(OPER_TYPE,
parv[1], source_p->username, source_p->realhost)) != NULL)
aconf = map_to_conf(conf);
//.........这里部分代码省略.........
示例15: CheckJuped
int
CheckJuped(char *name)
{
struct Jupe *tempjupe;
struct Server *tempserv;
char sendstr[MAXLINE + 1], **arv;
for (tempjupe = JupeList; tempjupe; tempjupe = tempjupe->next)
{
if (match(tempjupe->name, name))
{
if (tempjupe->isnick)
{
struct Luser *lptr;
if (!(lptr = FindClient(name)))
return 0;
/* its a nick jupe, not a server jupe */
#ifdef DANCER
ircsprintf(sendstr,
"NICK %s 1 %ld +i juped juped.com %s %lu :%s\r\n",
tempjupe->name,
#ifdef NICKSERVICES
(long) (lptr->nick_ts - 1),
#else
(long) (lptr->since - 1),
#endif /* NICKSERVICES */
Me.name, 0xffffffffL, tempjupe->reason ?
tempjupe->reason : "Jupitered Nickname");
#else
/* collide the nickname */
ircsprintf(sendstr, "NICK %s 1 %ld +i %s %s %s :%s\r\n",
tempjupe->name,
#ifdef NICKSERVICES
(long) (lptr->nick_ts - 1),
#else
(long) (lptr->since - 1),
#endif /* NICKSERVICES */
JUPED_USERNAME, JUPED_HOSTNAME, Me.name,
tempjupe->reason ? tempjupe->reason :
"Jupitered Nickname");
#endif /* DANCER */
toserv("%s", sendstr);
DeleteClient(lptr);
SplitBuf(sendstr, &arv);
AddClient(arv);
MyFree(arv);
if (Me.sptr)
Me.sptr->numoperkills++;
Network->TotalOperKills++;
#ifdef STATSERVICES
if (Network->TotalOperKills > Network->OperKillsT)
Network->OperKillsT = Network->TotalOperKills;
#endif
}
else
{
toserv("SQUIT %s :Juped: %s (%s)\r\n", name,
tempjupe->reason, tempjupe->who);
tempserv = FindServer(name);
DeleteServer(tempserv);
/* If the fake server is introduced before the remote server has quited,
* we get "server already exists" and services get SQUIT'ed,
* so we'll introduce it in s_squit()
*/
}
return 1;
}
}
return 0;
} /* CheckJuped */