rc: change plan9 envname limit to 128, cleanup

front
cinap_lenrek 2012-02-08 04:09:48 +01:00
parent 061d55111b
commit f2f19dd888
9 changed files with 36 additions and 32 deletions

View File

@ -22,10 +22,7 @@ int
morecode(void)
{
ncode+=100;
codebuf = (code *)realloc((char *)codebuf, ncode*sizeof codebuf[0]);
if(codebuf==0)
panic("Can't realloc %d bytes in morecode!",
ncode*sizeof codebuf[0]);
codebuf = (code *)erealloc((char *)codebuf, ncode*sizeof codebuf[0]);
return 0;
}

View File

@ -71,15 +71,6 @@ Xpipe(void)
}
}
char*
erealloc(char *p, long n)
{
p = realloc(p, n); /* botch, should be Realloc */
if(p==0)
panic("Can't realloc %d bytes\n", n);
return p;
}
/*
* Who should wait for the exit from the fork?
*/

View File

@ -51,15 +51,6 @@ Xasync(void)
setvar("apid", newword(buf, (word *)0));
}
char*
erealloc(char *p, long n)
{
p = realloc(p, n); /* botch, should be Realloc */
if(p==0)
panic("Can't realloc %d bytes\n", n);
return p;
}
enum { Stralloc = 100, };
void

View File

@ -178,9 +178,7 @@ flush(io *f)
if(f->strp){
n = f->ebuf - f->strp;
f->strp = realloc(f->strp, n+Stralloc+1);
if(f->strp==0)
panic("Can't realloc %d bytes in flush!", n+Stralloc+1);
f->strp = erealloc(f->strp, n+Stralloc+1);
f->bufp = f->strp + n;
f->ebuf = f->bufp + Stralloc;
memset(f->bufp, '\0', Stralloc+1);

View File

@ -10,7 +10,7 @@
#include "getflags.h"
enum {
Maxenvname = 256, /* undocumented limit */
Maxenvname = 128, /* undocumented limit */
};
char *Signame[] = {
@ -622,15 +622,19 @@ Malloc(ulong n)
return malloc(n);
}
void*
Realloc(void *p, ulong n)
{
return realloc(p, n);
}
int *waitpids;
int nwaitpids;
void
addwaitpid(int pid)
{
waitpids = realloc(waitpids, (nwaitpids+1)*sizeof waitpids[0]);
if(waitpids == 0)
panic("Can't realloc %d waitpids", nwaitpids+1);
waitpids = erealloc(waitpids, (nwaitpids+1)*sizeof waitpids[0]);
waitpids[nwaitpids++] = pid;
}

View File

@ -97,8 +97,11 @@ var *gvar[NVAR]; /* hash for globals */
#define new(type) ((type *)emalloc(sizeof(type)))
void *emalloc(long);
void *Malloc(ulong);
void *Realloc(void *, ulong);
void *emalloc(long);
void *erealloc(void *, long);
void efree(void *);
#define NOFILE 128 /* should come from <param.h> */

View File

@ -7,13 +7,21 @@ void *
emalloc(long n)
{
void *p = Malloc(n);
if(p==0)
panic("Can't malloc %d bytes", n);
/* if(err){ pfmt(err, "malloc %d->%p\n", n, p); flush(err); } /**/
return p;
}
void*
erealloc(void *p, long n)
{
p = Realloc(p, n); /* botch, should be Realloc */
if(p==0)
panic("Can't realloc %d bytes\n", n);
return p;
}
void
efree(void *p)
{

View File

@ -467,3 +467,9 @@ Malloc(n)
{
return (void *)malloc(n);
}
void*
Realloc(void *p, ulong n)
{
return realloc(p, n);
}

View File

@ -558,3 +558,9 @@ Malloc(ulong n)
{
return malloc(n);
}
void*
Realloc(void *p, ulong n)
{
return realloc(p, n);
}