mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-02-03 21:52:24 +00:00
Move the Mac port over to using snew/snewn/sresize.
[originally from svn r3024]
This commit is contained in:
parent
3e4386d810
commit
f599817d78
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macabout.c,v 1.2 2003/02/16 13:44:18 ben Exp $ */
|
/* $Id: macabout.c,v 1.3 2003/03/29 23:07:55 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2002, 2003 Ben Harris
|
* Copyright (c) 1999, 2002, 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -149,7 +149,7 @@ void mac_openabout(void)
|
|||||||
else {
|
else {
|
||||||
windows.about =
|
windows.about =
|
||||||
GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
|
GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
|
||||||
wi = smalloc(sizeof(*wi));
|
wi = snew(WinInfo);
|
||||||
memset(wi, 0, sizeof(*wi));
|
memset(wi, 0, sizeof(*wi));
|
||||||
wi->wtype = wAbout;
|
wi->wtype = wAbout;
|
||||||
wi->update = &mac_updateabout;
|
wi->update = &mac_updateabout;
|
||||||
@ -177,7 +177,7 @@ static void mac_openlicence(void)
|
|||||||
SelectWindow(windows.licence);
|
SelectWindow(windows.licence);
|
||||||
else {
|
else {
|
||||||
windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
|
windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
|
||||||
wi = smalloc(sizeof(*wi));
|
wi = snew(WinInfo);
|
||||||
memset(wi, 0, sizeof(*wi));
|
memset(wi, 0, sizeof(*wi));
|
||||||
wi->wtype = wLicence;
|
wi->wtype = wLicence;
|
||||||
wi->update = &mac_updatelicence;
|
wi->update = &mac_updatelicence;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macctrls.c,v 1.20 2003/03/29 22:04:21 ben Exp $ */
|
/* $Id: macctrls.c,v 1.21 2003/03/29 23:07:55 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003 Ben Harris
|
* Copyright (c) 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -223,7 +223,7 @@ void macctrl_layoutbox(struct controlbox *cb, WindowPtr window,
|
|||||||
for (i = 1; i < cb->nctrlsets; i++)
|
for (i = 1; i < cb->nctrlsets; i++)
|
||||||
if (strcmp(cb->ctrlsets[i]->pathname, cb->ctrlsets[i-1]->pathname))
|
if (strcmp(cb->ctrlsets[i]->pathname, cb->ctrlsets[i-1]->pathname))
|
||||||
mcs->npanels++;
|
mcs->npanels++;
|
||||||
mcs->panels = smalloc(sizeof(*mcs->panels) * mcs->npanels);
|
mcs->panels = snewn(mcs->npanels, union macctrl *);
|
||||||
memset(mcs->panels, 0, sizeof(*mcs->panels) * mcs->npanels);
|
memset(mcs->panels, 0, sizeof(*mcs->panels) * mcs->npanels);
|
||||||
curstate.panelnum = 0;
|
curstate.panelnum = 0;
|
||||||
for (i = 0; i < cb->nctrlsets; i++) {
|
for (i = 0; i < cb->nctrlsets; i++) {
|
||||||
@ -379,7 +379,7 @@ static void macctrl_text(struct macctrls *mcs, WindowPtr window,
|
|||||||
struct mac_layoutstate *curstate,
|
struct mac_layoutstate *curstate,
|
||||||
union control *ctrl)
|
union control *ctrl)
|
||||||
{
|
{
|
||||||
union macctrl *mc = smalloc(sizeof *mc);
|
union macctrl *mc = snew(union macctrl);
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
SInt16 height;
|
SInt16 height;
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ static void macctrl_editbox(struct macctrls *mcs, WindowPtr window,
|
|||||||
struct mac_layoutstate *curstate,
|
struct mac_layoutstate *curstate,
|
||||||
union control *ctrl)
|
union control *ctrl)
|
||||||
{
|
{
|
||||||
union macctrl *mc = smalloc(sizeof *mc);
|
union macctrl *mc = snew(union macctrl);
|
||||||
Rect lbounds, bounds;
|
Rect lbounds, bounds;
|
||||||
|
|
||||||
fprintf(stderr, " label = %s\n", ctrl->editbox.label);
|
fprintf(stderr, " label = %s\n", ctrl->editbox.label);
|
||||||
@ -553,7 +553,7 @@ static void macctrl_radio(struct macctrls *mcs, WindowPtr window,
|
|||||||
struct mac_layoutstate *curstate,
|
struct mac_layoutstate *curstate,
|
||||||
union control *ctrl)
|
union control *ctrl)
|
||||||
{
|
{
|
||||||
union macctrl *mc = smalloc(sizeof *mc);
|
union macctrl *mc = snew(union macctrl);
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
Str255 title;
|
Str255 title;
|
||||||
unsigned int i, colwidth;
|
unsigned int i, colwidth;
|
||||||
@ -562,8 +562,7 @@ static void macctrl_radio(struct macctrls *mcs, WindowPtr window,
|
|||||||
mc->generic.type = MACCTRL_RADIO;
|
mc->generic.type = MACCTRL_RADIO;
|
||||||
mc->generic.ctrl = ctrl;
|
mc->generic.ctrl = ctrl;
|
||||||
mc->generic.privdata = NULL;
|
mc->generic.privdata = NULL;
|
||||||
mc->radio.tbctrls =
|
mc->radio.tbctrls = snewn(ctrl->radio.nbuttons, ControlRef);
|
||||||
smalloc(sizeof(*mc->radio.tbctrls) * ctrl->radio.nbuttons);
|
|
||||||
colwidth = (curstate->width + 13) / ctrl->radio.ncolumns;
|
colwidth = (curstate->width + 13) / ctrl->radio.ncolumns;
|
||||||
bounds.top = curstate->pos.v;
|
bounds.top = curstate->pos.v;
|
||||||
bounds.bottom = bounds.top + 16;
|
bounds.bottom = bounds.top + 16;
|
||||||
@ -611,7 +610,7 @@ static void macctrl_checkbox(struct macctrls *mcs, WindowPtr window,
|
|||||||
struct mac_layoutstate *curstate,
|
struct mac_layoutstate *curstate,
|
||||||
union control *ctrl)
|
union control *ctrl)
|
||||||
{
|
{
|
||||||
union macctrl *mc = smalloc(sizeof *mc);
|
union macctrl *mc = snew(union macctrl);
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
Str255 title;
|
Str255 title;
|
||||||
|
|
||||||
@ -637,7 +636,7 @@ static void macctrl_button(struct macctrls *mcs, WindowPtr window,
|
|||||||
struct mac_layoutstate *curstate,
|
struct mac_layoutstate *curstate,
|
||||||
union control *ctrl)
|
union control *ctrl)
|
||||||
{
|
{
|
||||||
union macctrl *mc = smalloc(sizeof *mc);
|
union macctrl *mc = snew(union macctrl);
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
Str255 title;
|
Str255 title;
|
||||||
|
|
||||||
@ -723,7 +722,7 @@ static void macctrl_popup(struct macctrls *mcs, WindowPtr window,
|
|||||||
struct mac_layoutstate *curstate,
|
struct mac_layoutstate *curstate,
|
||||||
union control *ctrl)
|
union control *ctrl)
|
||||||
{
|
{
|
||||||
union macctrl *mc = smalloc(sizeof *mc);
|
union macctrl *mc = snew(union macctrl);
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
Str255 title;
|
Str255 title;
|
||||||
unsigned int labelwidth;
|
unsigned int labelwidth;
|
||||||
@ -1299,8 +1298,7 @@ static void dlg_macpopup_addwithid(union control *ctrl, void *dlg,
|
|||||||
index = CountMenuItems(menu) - 1;
|
index = CountMenuItems(menu) - 1;
|
||||||
if (mc->popup.nids <= index) {
|
if (mc->popup.nids <= index) {
|
||||||
mc->popup.nids = index + 1;
|
mc->popup.nids = index + 1;
|
||||||
mc->popup.ids = srealloc(mc->popup.ids,
|
mc->popup.ids = sresize(mc->popup.ids, mc->popup.nids, int);
|
||||||
mc->popup.nids * sizeof(*mc->popup.ids));
|
|
||||||
}
|
}
|
||||||
mc->popup.ids[index] = id;
|
mc->popup.ids[index] = id;
|
||||||
}
|
}
|
||||||
|
10
mac/macdlg.c
10
mac/macdlg.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macdlg.c,v 1.16 2003/03/25 23:18:59 ben Exp $ */
|
/* $Id: macdlg.c,v 1.17 2003/03/29 23:07:55 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 Ben Harris
|
* Copyright (c) 2002 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -54,7 +54,7 @@ void mac_newsession(void)
|
|||||||
WinInfo *wi;
|
WinInfo *wi;
|
||||||
static struct sesslist sesslist;
|
static struct sesslist sesslist;
|
||||||
|
|
||||||
s = smalloc(sizeof(*s));
|
s = snew(Session);
|
||||||
memset(s, 0, sizeof(*s));
|
memset(s, 0, sizeof(*s));
|
||||||
do_defaults(NULL, &s->cfg);
|
do_defaults(NULL, &s->cfg);
|
||||||
s->hasfile = FALSE;
|
s->hasfile = FALSE;
|
||||||
@ -71,7 +71,7 @@ void mac_newsession(void)
|
|||||||
s->settings_ctrls.data = &s->cfg;
|
s->settings_ctrls.data = &s->cfg;
|
||||||
macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls);
|
macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls);
|
||||||
|
|
||||||
wi = smalloc(sizeof(*wi));
|
wi = snew(WinInfo);
|
||||||
memset(wi, 0, sizeof(*wi));
|
memset(wi, 0, sizeof(*wi));
|
||||||
wi->s = s;
|
wi->s = s;
|
||||||
wi->mcs = &s->settings_ctrls;
|
wi->mcs = &s->settings_ctrls;
|
||||||
@ -102,7 +102,7 @@ void mac_dupsession(void)
|
|||||||
Session *s1 = mac_windowsession(FrontWindow());
|
Session *s1 = mac_windowsession(FrontWindow());
|
||||||
Session *s2;
|
Session *s2;
|
||||||
|
|
||||||
s2 = smalloc(sizeof(*s2));
|
s2 = snew(Session);
|
||||||
memset(s2, 0, sizeof(*s2));
|
memset(s2, 0, sizeof(*s2));
|
||||||
s2->cfg = s1->cfg;
|
s2->cfg = s1->cfg;
|
||||||
s2->hasfile = s1->hasfile;
|
s2->hasfile = s1->hasfile;
|
||||||
@ -118,7 +118,7 @@ static OSErr mac_opensessionfrom(FSSpec *fss)
|
|||||||
void *sesshandle;
|
void *sesshandle;
|
||||||
OSErr err;
|
OSErr err;
|
||||||
|
|
||||||
s = smalloc(sizeof(*s));
|
s = snew(Session);
|
||||||
memset(s, 0, sizeof(*s));
|
memset(s, 0, sizeof(*s));
|
||||||
|
|
||||||
err = FSpGetFInfo(fss, &fi);
|
err = FSpGetFInfo(fss, &fi);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macevlog.c,v 1.5 2003/02/23 13:00:38 ben Exp $ */
|
/* $Id: macevlog.c,v 1.6 2003/03/29 23:07:55 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003 Ben Harris
|
* Copyright (c) 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -58,7 +58,7 @@ static void mac_createeventlog(Session *s)
|
|||||||
WinInfo *wi;
|
WinInfo *wi;
|
||||||
|
|
||||||
s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1);
|
s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1);
|
||||||
wi = smalloc(sizeof(*wi));
|
wi = snew(WinInfo);
|
||||||
memset(wi, 0, sizeof(*wi));
|
memset(wi, 0, sizeof(*wi));
|
||||||
wi->s = s;
|
wi->s = s;
|
||||||
wi->wtype = wEventLog;
|
wi->wtype = wEventLog;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macmisc.c,v 1.2 2003/02/20 22:31:52 ben Exp $ */
|
/* $Id: macmisc.c,v 1.3 2003/03/29 23:07:55 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2003 Ben Harris
|
* Copyright (c) 1999, 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -119,7 +119,7 @@ const char *filename_to_str(const Filename *fn)
|
|||||||
char *newpath;
|
char *newpath;
|
||||||
|
|
||||||
if (path != NULL) sfree(path);
|
if (path != NULL) sfree(path);
|
||||||
path = smalloc(fn->fss.name[0]);
|
path = snewn(fn->fss.name[0], char);
|
||||||
p2cstrcpy(path, fn->fss.name);
|
p2cstrcpy(path, fn->fss.name);
|
||||||
pb.dirInfo.ioNamePtr = dirname;
|
pb.dirInfo.ioNamePtr = dirname;
|
||||||
pb.dirInfo.ioVRefNum = fn->fss.vRefNum;
|
pb.dirInfo.ioVRefNum = fn->fss.vRefNum;
|
||||||
@ -130,7 +130,7 @@ const char *filename_to_str(const Filename *fn)
|
|||||||
err = PBGetCatInfoSync(&pb);
|
err = PBGetCatInfoSync(&pb);
|
||||||
|
|
||||||
/* XXX Assume not A/UX */
|
/* XXX Assume not A/UX */
|
||||||
newpath = smalloc(strlen(path) + dirname[0] + 2);
|
newpath = snewn(strlen(path) + dirname[0] + 2, char);
|
||||||
p2cstrcpy(newpath, dirname);
|
p2cstrcpy(newpath, dirname);
|
||||||
strcat(newpath, ":");
|
strcat(newpath, ":");
|
||||||
strcat(newpath, path);
|
strcat(newpath, path);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macpgkey.c,v 1.3 2003/02/20 22:55:09 ben Exp $ */
|
/* $Id: macpgkey.c,v 1.4 2003/03/29 23:07:55 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003 Ben Harris
|
* Copyright (c) 2003 Ben Harris
|
||||||
* Copyright (c) 1997-2003 Simon Tatham
|
* Copyright (c) 1997-2003 Simon Tatham
|
||||||
@ -123,7 +123,7 @@ static void mac_clickkey(WindowPtr window, EventRecord *event)
|
|||||||
switch (item) {
|
switch (item) {
|
||||||
case wiKeyGenerate:
|
case wiKeyGenerate:
|
||||||
SetControlMaximum(ks->progress, 1024);
|
SetControlMaximum(ks->progress, 1024);
|
||||||
ks->entropy = smalloc(1024 * sizeof(*ks->entropy));
|
ks->entropy = snewn(1024, long);
|
||||||
ks->entropy_required = 1024;
|
ks->entropy_required = 1024;
|
||||||
ks->entropy_got = 0;
|
ks->entropy_got = 0;
|
||||||
ks->collecting_entropy = TRUE;
|
ks->collecting_entropy = TRUE;
|
||||||
@ -174,11 +174,11 @@ void mac_newkey(void)
|
|||||||
short type;
|
short type;
|
||||||
Rect rect;
|
Rect rect;
|
||||||
|
|
||||||
ks = smalloc(sizeof(*ks));
|
ks = snew(KeyState);
|
||||||
ks->box = GetNewDialog(wKey, NULL, (WindowPtr)-1);
|
ks->box = GetNewDialog(wKey, NULL, (WindowPtr)-1);
|
||||||
GetDialogItem(ks->box, wiKeyProgress, &type, &h, &rect);
|
GetDialogItem(ks->box, wiKeyProgress, &type, &h, &rect);
|
||||||
ks->progress = (ControlHandle)h;
|
ks->progress = (ControlHandle)h;
|
||||||
wi = smalloc(sizeof(*wi));
|
wi = snew(WinInfo);
|
||||||
memset(wi, 0, sizeof(*wi));
|
memset(wi, 0, sizeof(*wi));
|
||||||
wi->ks = ks;
|
wi->ks = ks;
|
||||||
wi->wtype = wKey;
|
wi->wtype = wKey;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macstore.c,v 1.17 2003/03/27 22:46:28 ben Exp $ */
|
/* $Id: macstore.c,v 1.18 2003/03/29 23:07:55 ben Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* macstore.c: Macintosh-specific impementation of the interface
|
* macstore.c: Macintosh-specific impementation of the interface
|
||||||
@ -149,7 +149,7 @@ void *open_settings_w_fsp(FSSpec *dstfile)
|
|||||||
OSErr error;
|
OSErr error;
|
||||||
Str255 tmpname;
|
Str255 tmpname;
|
||||||
|
|
||||||
ws = smalloc(sizeof *ws);
|
ws = snew(struct write_settings);
|
||||||
ws->dstfile = *dstfile;
|
ws->dstfile = *dstfile;
|
||||||
|
|
||||||
/* Create a temporary file to save to first. */
|
/* Create a temporary file to save to first. */
|
||||||
@ -278,7 +278,7 @@ void *open_settings_r_fsp(FSSpec *sessfile)
|
|||||||
fd = FSpOpenResFile(sessfile, fsRdPerm);
|
fd = FSpOpenResFile(sessfile, fsRdPerm);
|
||||||
if (fd == 0) {error = ResError(); goto out;}
|
if (fd == 0) {error = ResError(); goto out;}
|
||||||
|
|
||||||
handle = smalloc(sizeof *handle);
|
handle = snew(int);
|
||||||
*handle = fd;
|
*handle = fd;
|
||||||
return handle;
|
return handle;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macterm.c,v 1.71 2003/02/15 16:22:15 ben Exp $ */
|
/* $Id: macterm.c,v 1.72 2003/03/29 23:07:55 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Simon Tatham
|
* Copyright (c) 1999 Simon Tatham
|
||||||
* Copyright (c) 1999, 2002 Ben Harris
|
* Copyright (c) 1999, 2002 Ben Harris
|
||||||
@ -129,7 +129,7 @@ void mac_startsession(Session *s)
|
|||||||
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
|
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
|
||||||
else
|
else
|
||||||
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
|
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
|
||||||
wi = smalloc(sizeof(*wi));
|
wi = snew(WinInfo);
|
||||||
memset(wi, 0, sizeof(*wi));
|
memset(wi, 0, sizeof(*wi));
|
||||||
wi->s = s;
|
wi->s = s;
|
||||||
wi->wtype = wTerminal;
|
wi->wtype = wTerminal;
|
||||||
@ -629,7 +629,7 @@ void write_clip(void *cookie, wchar_t *data, int len, int must_deselect)
|
|||||||
if (data[i] == 0x2028)
|
if (data[i] == 0x2028)
|
||||||
data[i] = 0x000d;
|
data[i] = 0x000d;
|
||||||
|
|
||||||
mactextbuf = smalloc(len); /* XXX DBCS */
|
mactextbuf = snewn(len, char); /* XXX DBCS */
|
||||||
if (s->uni_to_font != NULL) {
|
if (s->uni_to_font != NULL) {
|
||||||
err = ConvertFromUnicodeToText(s->uni_to_font, len * sizeof(UniChar),
|
err = ConvertFromUnicodeToText(s->uni_to_font, len * sizeof(UniChar),
|
||||||
(UniChar *)data,
|
(UniChar *)data,
|
||||||
@ -702,7 +702,7 @@ void get_clip(void *frontend, wchar_t **p, int *lenp)
|
|||||||
texth = NewHandle(0);
|
texth = NewHandle(0);
|
||||||
textlen = GetScrap(texth, kScrapFlavorTypeText, &offset);
|
textlen = GetScrap(texth, kScrapFlavorTypeText, &offset);
|
||||||
HLock(texth);
|
HLock(texth);
|
||||||
data = smalloc(textlen * 2);
|
data = snewn(textlen, wchar_t);
|
||||||
/* XXX should use 'styl' scrap if it's there. */
|
/* XXX should use 'styl' scrap if it's there. */
|
||||||
if (mac_gestalts.encvvers != 0 &&
|
if (mac_gestalts.encvvers != 0 &&
|
||||||
UpgradeScriptInfoToTextEncoding(smSystemScript,
|
UpgradeScriptInfoToTextEncoding(smSystemScript,
|
||||||
|
@ -275,7 +275,7 @@ static ResultUPP mactcp_lookupdone_upp;
|
|||||||
|
|
||||||
SockAddr mactcp_namelookup(char const *host, char **canonicalname)
|
SockAddr mactcp_namelookup(char const *host, char **canonicalname)
|
||||||
{
|
{
|
||||||
SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
|
SockAddr ret = snew(struct SockAddr_tag);
|
||||||
OSErr err;
|
OSErr err;
|
||||||
volatile int done = FALSE;
|
volatile int done = FALSE;
|
||||||
char *realhost;
|
char *realhost;
|
||||||
@ -305,7 +305,7 @@ SockAddr mactcp_namelookup(char const *host, char **canonicalname)
|
|||||||
realhost[realhostlen - 1] = '\0';
|
realhost[realhostlen - 1] = '\0';
|
||||||
} else
|
} else
|
||||||
realhost = "";
|
realhost = "";
|
||||||
*canonicalname = smalloc(1+strlen(realhost));
|
*canonicalname = snewn(1 + strlen(realhost), char);
|
||||||
strcpy(*canonicalname, realhost);
|
strcpy(*canonicalname, realhost);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ static pascal void mactcp_lookupdone(struct hostInfo *hi, char *cookie)
|
|||||||
|
|
||||||
SockAddr mactcp_nonamelookup(char const *host)
|
SockAddr mactcp_nonamelookup(char const *host)
|
||||||
{
|
{
|
||||||
SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
|
SockAddr ret = snew(struct SockAddr_tag);
|
||||||
|
|
||||||
ret->resolved = FALSE;
|
ret->resolved = FALSE;
|
||||||
ret->hostinfo.rtnCode = noErr;
|
ret->hostinfo.rtnCode = noErr;
|
||||||
@ -432,7 +432,7 @@ Socket mactcp_new(SockAddr addr, int port, int privport, int oobinline,
|
|||||||
/*
|
/*
|
||||||
* Create Socket structure.
|
* Create Socket structure.
|
||||||
*/
|
*/
|
||||||
ret = smalloc(sizeof(struct Socket_tag));
|
ret = snew(struct Socket_tag);
|
||||||
ret->s = 0;
|
ret->s = 0;
|
||||||
ret->fn = &fn_table;
|
ret->fn = &fn_table;
|
||||||
ret->err = noErr;
|
ret->err = noErr;
|
||||||
@ -473,7 +473,7 @@ Socket mactcp_new(SockAddr addr, int port, int privport, int oobinline,
|
|||||||
GetCurrentProcess(&mactcp.self);
|
GetCurrentProcess(&mactcp.self);
|
||||||
pb.ioCRefNum = mactcp.refnum;
|
pb.ioCRefNum = mactcp.refnum;
|
||||||
pb.csCode = TCPCreate;
|
pb.csCode = TCPCreate;
|
||||||
pb.csParam.create.rcvBuff = smalloc(buflen);
|
pb.csParam.create.rcvBuff = snewn(buflen, char);
|
||||||
pb.csParam.create.rcvBuffLen = buflen;
|
pb.csParam.create.rcvBuffLen = buflen;
|
||||||
pb.csParam.create.notifyProc = mactcp_asr_upp;
|
pb.csParam.create.notifyProc = mactcp_asr_upp;
|
||||||
pb.csParam.create.userDataPtr = (Ptr)ret;
|
pb.csParam.create.userDataPtr = (Ptr)ret;
|
||||||
|
10
mac/otnet.c
10
mac/otnet.c
@ -81,7 +81,7 @@ void ot_cleanup(void)
|
|||||||
|
|
||||||
SockAddr ot_namelookup(char const *host, char **canonicalname)
|
SockAddr ot_namelookup(char const *host, char **canonicalname)
|
||||||
{
|
{
|
||||||
SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
|
SockAddr ret = snew(struct SockAddr_tag);
|
||||||
char *realhost;
|
char *realhost;
|
||||||
|
|
||||||
/* Casting away const -- hope OTInetStringToAddress is sensible */
|
/* Casting away const -- hope OTInetStringToAddress is sensible */
|
||||||
@ -93,14 +93,14 @@ SockAddr ot_namelookup(char const *host, char **canonicalname)
|
|||||||
realhost = ret->hostinfo.name;
|
realhost = ret->hostinfo.name;
|
||||||
else
|
else
|
||||||
realhost = "";
|
realhost = "";
|
||||||
*canonicalname = smalloc(1+strlen(realhost));
|
*canonicalname = snewn(1+strlen(realhost), char);
|
||||||
strcpy(*canonicalname, realhost);
|
strcpy(*canonicalname, realhost);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SockAddr ot_nonamelookup(char const *host)
|
SockAddr ot_nonamelookup(char const *host)
|
||||||
{
|
{
|
||||||
SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
|
SockAddr ret = snew(struct SockAddr_tag);
|
||||||
|
|
||||||
ret->resolved = FALSE;
|
ret->resolved = FALSE;
|
||||||
ret->error = kOTNoError;
|
ret->error = kOTNoError;
|
||||||
@ -205,7 +205,7 @@ Socket ot_register(void *sock, Plug plug)
|
|||||||
|
|
||||||
Actual_Socket ret;
|
Actual_Socket ret;
|
||||||
|
|
||||||
ret = smalloc(sizeof(struct Socket_tag));
|
ret = snew(struct Socket_tag);
|
||||||
ret->fn = &fn_table;
|
ret->fn = &fn_table;
|
||||||
ret->error = kOTNoError;
|
ret->error = kOTNoError;
|
||||||
ret->plug = plug;
|
ret->plug = plug;
|
||||||
@ -254,7 +254,7 @@ Socket ot_new(SockAddr addr, int port, int privport, int oobinline,
|
|||||||
InetAddress dest;
|
InetAddress dest;
|
||||||
TCall connectCall;
|
TCall connectCall;
|
||||||
|
|
||||||
ret = smalloc(sizeof(struct Socket_tag));
|
ret = snew(struct Socket_tag);
|
||||||
ret->fn = &fn_table;
|
ret->fn = &fn_table;
|
||||||
ret->error = kOTNoError;
|
ret->error = kOTNoError;
|
||||||
ret->plug = plug;
|
ret->plug = plug;
|
||||||
|
Loading…
Reference in New Issue
Block a user