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
8c890fa4
...
8c890fa48ddfd15c1beae99e7adf4473362d63f4
authored
2006-01-20 16:36:18 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
New file
1 parent
02757b7c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
mailbox/mu_umaxtostr.c
mailbox/mu_umaxtostr.h
mailbox/mu_umaxtostr.c
0 → 100644
View file @
8c890fa
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2005 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mu_umaxtostr.h>
static
char
**
buffer_pool
;
static
size_t
buffer_size
;
#define BUFFER_SIZE_INIT 4
#define BUFFER_SIZE_INCR 4
static
char
*
get_buffer
(
unsigned
slot
)
{
if
(
!
buffer_pool
)
{
buffer_size
=
BUFFER_SIZE_INIT
;
buffer_pool
=
calloc
(
buffer_size
,
sizeof
*
buffer_pool
);
}
else
if
(
slot
>=
buffer_size
)
{
buffer_size
+=
(
slot
+
BUFFER_SIZE_INCR
-
1
)
/
BUFFER_SIZE_INCR
;
buffer_pool
=
realloc
(
buffer_pool
,
buffer_size
*
sizeof
*
buffer_pool
);
}
if
(
!
buffer_pool
)
return
NULL
;
if
(
buffer_pool
[
slot
]
==
NULL
)
buffer_pool
[
slot
]
=
malloc
(
UINTMAX_STRSIZE_BOUND
);
return
buffer_pool
[
slot
];
}
const
char
*
mu_umaxtostr
(
unsigned
slot
,
uintmax_t
val
)
{
char
*
s
=
get_buffer
(
slot
);
if
(
!
s
)
return
mu_strerror
(
ENOMEM
);
return
umaxtostr
(
val
,
s
);
}
mailbox/mu_umaxtostr.h
0 → 100644
View file @
8c890fa
#include <inttostr.h>
#define UINTMAX_STRSIZE_BOUND INT_BUFSIZE_BOUND (uintmax_t)
const
char
*
mu_umaxtostr
(
unsigned
slot
,
uintmax_t
val
);
Please
register
or
sign in
to post a comment