From: Goffredo Baroncelli <kreijack@inwind.it>
To: linux-btrfs@vger.kernel.org
Subject: [BTRFS-PROG][PATCH 2/7] helpextract.c: removed some static buffer
Date: Wed, 02 Nov 2011 22:23:10 +0100 [thread overview]
Message-ID: <1538956.XgfiHE93Xx@venice> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1523 bytes --]
Removed some static buffer, and replaced by a dynamic memory allocation
in order to support bigger text.
Comments are welcome.
BR
G.Baroncelli
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
---
| 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
--git a/helpextract.c b/helpextract.c
index a729074..e708b9e 100644
--- a/helpextract.c
+++ b/helpextract.c
@@ -9,7 +9,7 @@
#define PREFIX_END " ****"
#define PREFIX_SKIP " * "
-#define LINEBUF 1024
+#define LINEBUF 4024
char **msgs=0;
int nmsg=0;
@@ -188,7 +188,9 @@ static int search_in_file(char *nf){
/* remove all the escape sequence except \\ */
static char * my_escape(char *src, char *filters[] ){
- static char buffer[LINEBUF*5];
+ char *buffer=NULL;
+
+ buffer = xrealloc(buffer, strlen(src)*2+1);
int i=0;
while(*src){
@@ -387,14 +389,15 @@ static void dump_man_page(){
fmt = find_section("man btrfs command format");
for(i = 0; i < nmsg && fmt>=0; i++ ){
- char big2[LINEBUF*5];
+ char *big2;
if( strncmp("btrfs ",msgs[i*4], 6) ||
!strcmp("btrfs introduction", msgs[i*4] ) ||
!strcmp("btrfs notes", msgs[i*4] ) )
continue;
- strcpy(big2, escape_man_page(msgs[i*4+3]));
+ big2 = xstrdup(escape_man_page(msgs[i*4+3]));
printf(msgs[fmt*4+3], escape_man_page(msgs[i*4+1]), big2);
+ free(big2);
}
--
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack@inwind.it>
Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512
[-- Attachment #1.2: send-via-kmail-attach-3522-1320267550-26913.msg --]
[-- Type: text/x-patch, Size: 1081 bytes --]
diff --git a/helpextract.c b/helpextract.c
index a729074..e708b9e 100644
--- a/helpextract.c
+++ b/helpextract.c
@@ -9,7 +9,7 @@
#define PREFIX_END " ****"
#define PREFIX_SKIP " * "
-#define LINEBUF 1024
+#define LINEBUF 4024
char **msgs=0;
int nmsg=0;
@@ -188,7 +188,9 @@ static int search_in_file(char *nf){
/* remove all the escape sequence except \\ */
static char * my_escape(char *src, char *filters[] ){
- static char buffer[LINEBUF*5];
+ char *buffer=NULL;
+
+ buffer = xrealloc(buffer, strlen(src)*2+1);
int i=0;
while(*src){
@@ -387,14 +389,15 @@ static void dump_man_page(){
fmt = find_section("man btrfs command format");
for(i = 0; i < nmsg && fmt>=0; i++ ){
- char big2[LINEBUF*5];
+ char *big2;
if( strncmp("btrfs ",msgs[i*4], 6) ||
!strcmp("btrfs introduction", msgs[i*4] ) ||
!strcmp("btrfs notes", msgs[i*4] ) )
continue;
- strcpy(big2, escape_man_page(msgs[i*4+3]));
+ big2 = xstrdup(escape_man_page(msgs[i*4+3]));
printf(msgs[fmt*4+3], escape_man_page(msgs[i*4+1]), big2);
+ free(big2);
}
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
reply other threads:[~2011-11-02 21:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1538956.XgfiHE93Xx@venice \
--to=kreijack@inwind.it \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox