Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
5a5f7a59
...
5a5f7a591e6264b35b961655c339fc998994ba45
authored
2001-07-09 07:47:29 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added util_malloc(), util_calloc().
1 parent
a7645e9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
22 deletions
mail/mail.h
mail/util.c
mail/mail.h
View file @
5a5f7a5
...
...
@@ -242,6 +242,8 @@ void util_save_outgoing __P((message_t msg, char *savefile));
void
util_error
__P
((
const
char
*
format
,
...));
int
util_help
__P
((
const
struct
mail_command_entry
*
table
,
char
*
word
));
int
util_tempfile
__P
((
char
**
namep
));
void
*
util_malloc
__P
((
size_t
size
));
void
*
util_calloc
__P
((
size_t
nitems
,
size_t
size
));
int
ml_got_interrupt
__P
((
void
));
void
ml_clear_interrupt
__P
((
void
));
...
...
mail/util.c
View file @
5a5f7a5
...
...
@@ -41,7 +41,7 @@ static node *env_cursor = NULL;
static
node
*
util_ll_add
(
node
*
c
,
int
data
)
{
c
->
next
=
malloc
(
sizeof
(
node
));
c
->
next
=
util_
malloc
(
sizeof
(
node
));
c
->
data
=
data
;
c
->
next
->
env_entry
.
var
=
NULL
;
c
->
next
->
env_entry
.
set
=
0
;
...
...
@@ -80,7 +80,7 @@ util_expand_msglist (const int argc, char **argv, int **list)
int
undelete
=
0
;
int
*
ret
=
NULL
;
/* let's try a linked list */
node
*
first
=
malloc
(
sizeof
(
node
));
node
*
first
=
util_
malloc
(
sizeof
(
node
));
node
*
current
=
first
;
first
->
next
=
NULL
;
...
...
@@ -150,7 +150,7 @@ util_expand_msglist (const int argc, char **argv, int **list)
{
/* all messages */
util_ll_free
(
first
);
current
=
first
=
malloc
(
sizeof
(
node
));
current
=
first
=
util_
malloc
(
sizeof
(
node
));
for
(
i
=
1
;
i
<=
total
;
i
++
)
current
=
util_ll_add
(
current
,
i
);
i
=
argc
+
1
;
...
...
@@ -237,23 +237,13 @@ util_expand_msglist (const int argc, char **argv, int **list)
if
(
!
lc
)
{
ret
=
calloc
(
1
,
sizeof
(
int
));
if
(
!
ret
)
{
util_error
(
"not enough memory"
);
exit
(
1
);
}
ret
=
util_calloc
(
1
,
sizeof
(
int
));
ret
[
0
]
=
cursor
;
lc
=
1
;
}
else
{
ret
=
malloc
(
lc
*
sizeof
(
int
));
if
(
!
ret
)
{
util_error
(
"not enough memory"
);
exit
(
1
);
}
ret
=
util_malloc
(
lc
*
sizeof
(
int
));
lc
=
0
;
for
(
current
=
first
;
current
->
next
!=
NULL
;
current
=
current
->
next
)
ret
[
lc
++
]
=
current
->
data
;
...
...
@@ -482,7 +472,7 @@ util_find_env (const char *variable)
if
(
environment
==
NULL
)
{
environment
=
malloc
(
sizeof
(
node
));
environment
=
util_
malloc
(
sizeof
(
node
));
environment
->
env_entry
.
var
=
NULL
;
environment
->
env_entry
.
set
=
0
;
environment
->
env_entry
.
value
=
NULL
;
...
...
@@ -790,12 +780,7 @@ util_escape_percent (char **str)
return
;
/* nothing to do */
/* expand the string */
newstr
=
malloc
(
strlen
(
*
str
)
+
1
+
count
);
if
(
!
newstr
)
{
util_error
(
"not enough memory"
);
exit
(
1
);
/* be on the safe side */
}
newstr
=
util_malloc
(
strlen
(
*
str
)
+
1
+
count
);
/* and escape percent signs */
p
=
newstr
;
...
...
@@ -1005,3 +990,26 @@ util_tempfile(char **namep)
return
fd
;
}
void
*
util_malloc
(
size_t
size
)
{
void
*
p
=
malloc
(
size
);
if
(
!
p
)
{
util_error
(
"not enough memory (allocating %d bytes)"
,
size
);
abort
();
}
return
p
;
}
void
*
util_calloc
(
size_t
nitems
,
size_t
size
)
{
void
*
p
;
size
*=
nitems
;
p
=
util_malloc
(
size
);
memset
(
p
,
0
,
size
);
return
p
;
}
...
...
Please
register
or
sign in
to post a comment