+2008-01-21 Guillem Jover <guillem@debian.org>
+
+ * dpkg-deb/build.c (getfi): Use m_malloc instead of malloc.
+ (do_build): Likewise.
+ * dpkg-deb/extract.c (extracthalf): Likewise.
+ * lib/mlib.c (buffer_write): Likewise.
+ (buffer_copy): Likewise.
+ * lib/myopt.c (loadcfgfile): Likewise.
+ * lib/parse.c (parsedb): Likewise.
+ * lib/showpkg.c (alloclstitem): Likewise.
+ (parsefield): Likewise.
+ (parsestring): Likewise.
+ * lib/tarfn.c (StoC): Likewise.
+ (TarExtractor): Likewise.
+ * src/archives.c (try_deconfigure_can): Likewise.
+ * src/main.c (execbackend): Likewise.
+
2008-01-21 Guillem Jover <guillem@debian.org>
* lib/mlib.c (m_strdup): New function.
if (fn == NULL) {
fnlen = rl + MAXFILENAME;
- fn=(char*)malloc(fnlen);
+ fn = m_malloc(fnlen);
} else if (fnlen < (rl + MAXFILENAME)) {
fnlen = rl + MAXFILENAME;
fn=(char*)realloc(fn,fnlen);
ohshit(_("file name '%.50s...' is too long"), fn + rl + 1);
}
- fi=(struct _finfo*)malloc(sizeof(struct _finfo));
+ fi = m_malloc(sizeof(struct _finfo));
lstat(fn, &(fi->st));
fi->fn = m_strdup(fn + rl + 1);
fi->next=NULL;
/* template for our tempfiles */
if ((envbuf= getenv("TMPDIR")) == NULL)
envbuf= P_tmpdir;
- tfbuf = (char *)malloc(strlen(envbuf)+13);
+ tfbuf = m_malloc(strlen(envbuf) + 13);
strcpy(tfbuf,envbuf);
strcat(tfbuf,"/dpkg.XXXXXX");
subdir= 0;
(long) (stab.st_size - ctrllennum - strlen(ctrllenbuf) - l)) == EOF ||
fflush(stdout)) werr("stdout");
- ctrlarea = malloc(ctrllennum);
- if (!ctrlarea)
- ohshite(_("failed allocating memory for variable `ctrlarea'"));
+ ctrlarea = m_malloc(ctrllennum);
errno=0; if (fread(ctrlarea,1,ctrllennum,ar) != ctrllennum)
readfail(ar, debar, _("control area"));
switch(data->type ^ BUFFER_WRITE_SETUP) {
case BUFFER_WRITE_MD5:
{
- struct buffer_write_md5ctx *ctx = malloc(sizeof(struct buffer_write_md5ctx));
+ struct buffer_write_md5ctx *ctx;
+
+ ctx = m_malloc(sizeof(struct buffer_write_md5ctx));
ctx->hash = data->data.ptr;
data->data.ptr = ctx;
MD5Init(&ctx->ctx);
int i;
unsigned char digest[16], *p = digest;
struct buffer_write_md5ctx *ctx = (struct buffer_write_md5ctx *)data->data.ptr;
- unsigned char *hash = *ctx->hash = malloc(33);
+ unsigned char *hash = *ctx->hash = m_malloc(33);
MD5Final(digest, &ctx->ctx);
for (i = 0; i < 16; ++i) {
sprintf((char *)hash, "%02x", *p++);
if((limit!=-1) && (limit < bufsize)) bufsize= limit;
if(bufsize == 0)
return 0;
- writebuf= buf= malloc(bufsize);
- if(buf== NULL) ohshite(_("failed to allocate buffer in buffer_copy (%s)"), desc);
+ writebuf = buf= m_malloc(bufsize);
while(bytesread >= 0 && byteswritten >= 0 && bufsize > 0) {
bytesread= read_data->proc(read_data, buf, bufsize, desc);
char *home, *file;
int l1, l2;
l1 = strlen(CONFIGDIR "/.cfg") + strlen(prog);
- file = malloc(l1 + 1);
- if (file==NULL) ohshite(_("Error allocating memory for cfgfilename"));
+ file = m_malloc(l1 + 1);
sprintf(file, CONFIGDIR "/%s.cfg", prog);
myfileopt(file, cmdinfos);
if ((home = getenv("HOME")) != NULL) {
l2 = strlen(home) + 1 + strlen("/.cfg") + strlen(prog);
if (l2 > l1) {
free(file);
- file = malloc(l2 + 1);
- if (file==NULL) ohshite(_("Error allocating memory for cfgfilename"));
+ file = m_malloc(l2 + 1);
}
sprintf(file, "%s/.%s.cfg", home, prog);
myfileopt(file, cmdinfos);
if ((dataptr= (char *)mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED)
ohshite(_("can't mmap package info file `%.255s'"),filename);
#else
- if ((dataptr= malloc(stat.st_size)) == NULL)
- ohshite(_("failed to malloc for info file `%.255s'"),filename);
+ dataptr = m_malloc(stat.st_size);
fd_buf_copy(fd, dataptr, stat.st_size, _("copy info file `%.255s'"),filename);
#endif
static struct lstitem* alloclstitem(void) {
struct lstitem* buf;
- buf=(struct lstitem*)malloc(sizeof(struct lstitem));
+ buf = m_malloc(sizeof(struct lstitem));
buf->type=invalid;
buf->next=NULL;
buf->data=NULL;
}
cur->type=field;
- cur->data=(char*)malloc(len+1);
+ cur->data = m_malloc(len + 1);
memcpy(cur->data, fmt, len);
cur->data[len]='\0';
len=fmtend-fmt+1;
cur->type=string;
- write=cur->data=(char*)malloc(len+1);
+ write = cur->data = m_malloc(len + 1);
while (fmt<=fmtend) {
if (*fmt=='\\') {
fmt++;
char * str;
len = strnlen(s, size);
- str = malloc(len + 1);
+ str = m_malloc(len + 1);
memcpy(str, s, len);
str[len] = 0;
next_long_name = NULL;
next_long_link = NULL;
long_read = 0;
- symListBottom = symListPointer = symListTop = malloc(sizeof(symlinkList));
+ symListBottom = symListPointer = symListTop = m_malloc(sizeof(symlinkList));
symListTop->next = NULL;
h.UserData = userData;
memcpy(&symListBottom->h, &h, sizeof(TarInfo));
symListBottom->h.Name = m_strdup(h.Name);
symListBottom->h.LinkName = m_strdup(h.LinkName);
- if ((symListBottom->next = malloc(sizeof(symlinkList))) == NULL) {
- free(symListBottom->h.LinkName);
- free(symListBottom->h.Name);
- status = -1;
- errno = 0;
- break;
- }
+ symListBottom->next = m_malloc(sizeof(symlinkList));
+
symListBottom = symListBottom->next;
symListBottom->next = NULL;
status = 0;
if (*longp)
free(*longp);
- if (NULL == (*longp = (char *)malloc(h.Size))) {
- /* malloc failed, so bail */
- errno = 0;
- status = -1;
- break;
- }
+ *longp = m_malloc(h.Size);
bp = *longp;
// the way the GNU long{link,name} stuff works is like this:
}
}
pkg->clientdata->istobe= itb_deconfigure;
- newdeconf= malloc(sizeof(struct packageinlist));
+ newdeconf = m_malloc(sizeof(struct packageinlist));
newdeconf->next= deconfigure;
newdeconf->pkg= pkg;
newdeconf->xinfo= removal;
pass_admindir = 1;
}
- nargv = malloc(sizeof(char *) * (argc + 2));
- if (!nargv)
- ohshite(_("couldn't malloc in execbackend"));
-
+ nargv = m_malloc(sizeof(char *) * (argc + 2));
nargv[i] = m_strdup(cipaction->parg);
i++, offset++;
if (pass_admindir) {
- nargv[i] = malloc((strlen("--admindir=") + strlen(admindir) + 1));
- if (!nargv[i])
- ohshite(_("couldn't malloc in execbackend"));
-
+ nargv[i] = m_malloc((strlen("--admindir=") + strlen(admindir) + 1));
sprintf(nargv[i], "--admindir=%s", admindir);
i++, offset++;
}
- nargv[i] = malloc(2 + strlen(cipaction->olong) + 1);
- if (!nargv[i])
- ohshite(_("couldn't malloc in execbackend"));
+ nargv[i] = m_malloc(2 + strlen(cipaction->olong) + 1);
strcpy(nargv[i], "--");
strcat(nargv[i], cipaction->olong);
i++, offset++;