summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2019-11-18 21:07:35 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2019-11-20 22:09:25 +0000
commit7671892300b0044b85ba289a7afb32e640b5b07d (patch)
tree59f9e9579d2ffaab6e58fa36368384de9d49fc33 /utils
parentd331bfe09816397d5f6c8ef9744c418bc6063fe9 (diff)
Have more strings on the stack, rather than on the heap
And replace some GooString with std::string while we're at it.
Diffstat (limited to 'utils')
-rw-r--r--utils/HtmlFonts.cc21
-rw-r--r--utils/HtmlOutputDev.cc49
2 files changed, 25 insertions, 45 deletions
diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc
index 5310121d..b16cb4cb 100644
--- a/utils/HtmlFonts.cc
+++ b/utils/HtmlFonts.cc
@@ -276,29 +276,23 @@ int HtmlFontAccu::AddFont(const HtmlFont& font){
// get CSS font definition for font #i
GooString* HtmlFontAccu::CSStyle(int i, int j){
GooString *tmp=new GooString();
- GooString *iStr=new GooString(std::to_string(i));
- GooString *jStr=new GooString(std::to_string(j));
std::vector<HtmlFont>::iterator g=accu->begin();
g+=i;
HtmlFont font=*g;
- GooString *Size=new GooString(std::to_string(font.getSize()));
GooString *colorStr=font.getColor().toString();
GooString *fontName=(fontFullName ? font.getFullName() : font.getFontName());
- GooString *lSize;
if(!xml){
tmp->append(".ft");
- tmp->append(jStr);
- tmp->append(iStr);
+ tmp->append(std::to_string(j));
+ tmp->append(std::to_string(i));
tmp->append("{font-size:");
- tmp->append(Size);
+ tmp->append(std::to_string(font.getSize()));
if( font.getLineSize() != -1 && font.getLineSize() != 0 )
{
- lSize = new GooString(std::to_string(font.getLineSize()));
tmp->append("px;line-height:");
- tmp->append(lSize);
- delete lSize;
+ tmp->append(std::to_string(font.getLineSize()));
}
tmp->append("px;font-family:");
tmp->append(fontName); //font.getFontName());
@@ -331,9 +325,9 @@ GooString* HtmlFontAccu::CSStyle(int i, int j){
}
if (xml) {
tmp->append("<fontspec id=\"");
- tmp->append(iStr);
+ tmp->append(std::to_string(i));
tmp->append("\" size=\"");
- tmp->append(Size);
+ tmp->append(std::to_string(font.getSize()));
tmp->append("\" family=\"");
tmp->append(fontName);
tmp->append("\" color=\"");
@@ -343,9 +337,6 @@ GooString* HtmlFontAccu::CSStyle(int i, int j){
delete fontName;
delete colorStr;
- delete jStr;
- delete iStr;
- delete Size;
return tmp;
}
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index 306bb416..ca4d4aaa 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -810,39 +810,34 @@ static void printCSS(FILE *f)
}
int HtmlPage::dumpComplexHeaders(FILE * const file, FILE *& pageFile, int page) {
- GooString* tmp;
if( !noframes )
{
- GooString* pgNum=new GooString(std::to_string(page));
- tmp = new GooString(DocName);
+ const std::string pgNum = std::to_string(page);
+ std::string pageFileName(DocName->toStr());
if (!singleHtml){
- tmp->append('-')->append(pgNum)->append(".html");
- pageFile = fopen(tmp->c_str(), "w");
+ pageFileName += '-' + pgNum + ".html";
+ pageFile = fopen(pageFileName.c_str(), "w");
} else {
- tmp->append("-html")->append(".html");
- pageFile = fopen(tmp->c_str(), "a");
+ pageFileName += "-html.html";
+ pageFile = fopen(pageFileName.c_str(), "a");
}
- delete pgNum;
+
if (!pageFile) {
- error(errIO, -1, "Couldn't open html file '{0:t}'", tmp);
- delete tmp;
+ error(errIO, -1, "Couldn't open html file '{0:t}'", pageFileName.c_str());
return 1;
}
if (!singleHtml)
fprintf(pageFile,"%s\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n<title>Page %d</title>\n\n", DOCTYPE, page);
else
- fprintf(pageFile,"%s\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n<title>%s</title>\n\n", DOCTYPE, tmp->c_str());
-
- delete tmp;
+ fprintf(pageFile,"%s\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n<title>%s</title>\n\n", DOCTYPE, pageFileName.c_str());
- GooString *htmlEncoding = HtmlOutputDev::mapEncodingToHtml(globalParams->getTextEncodingName());
+ const std::string htmlEncoding = HtmlOutputDev::mapEncodingToHtml(globalParams->getTextEncodingName())->toStr();
if (!singleHtml)
- fprintf(pageFile, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->c_str());
+ fprintf(pageFile, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding.c_str());
else
- fprintf(pageFile, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n <br/>\n", htmlEncoding->c_str());
- delete htmlEncoding;
+ fprintf(pageFile, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n <br/>\n", htmlEncoding.c_str());
}
else
{
@@ -1577,7 +1572,6 @@ GooString* HtmlOutputDev::getLinkDest(AnnotLink *link){
delete dest;
- GooString *str=new GooString(std::to_string(destPage));
/* complex simple
frames file-4.html files.html#4
noframes file.html#4 file.html#4
@@ -1585,25 +1579,24 @@ GooString* HtmlOutputDev::getLinkDest(AnnotLink *link){
if (noframes)
{
file->append(".html#");
- file->append(str);
+ file->append(std::to_string(destPage));
}
else
{
if( complexMode )
{
file->append("-");
- file->append(str);
+ file->append(std::to_string(destPage));
file->append(".html");
}
else
{
file->append("s.html#");
- file->append(str);
+ file->append(std::to_string(destPage));
}
}
if (printCommands) printf(" link to page %d ",destPage);
- delete str;
return file;
}
else
@@ -1634,9 +1627,7 @@ GooString* HtmlOutputDev::getLinkDest(AnnotLink *link){
file->append(".html");
}
file->append('#');
- GooString *pgNum = new GooString(std::to_string(destPage));
- file->append(pgNum);
- delete pgNum;
+ file->append(std::to_string(destPage));
}
}
if (printCommands && file) printf("filename %s\n",file->c_str());
@@ -1777,21 +1768,19 @@ bool HtmlOutputDev::newHtmlOutlineLevel(FILE *output, const std::vector<OutlineI
noframes file.html#4 file.html#4
*/
linkName = new GooString(gbasename(Docname->c_str()));
- GooString *str = new GooString(std::to_string(itemPage));
if (noframes) {
linkName->append(".html#");
- linkName->append(str);
+ linkName->append(std::to_string(itemPage));
} else {
if( complexMode ) {
linkName->append("-");
- linkName->append(str);
+ linkName->append(std::to_string(itemPage));
linkName->append(".html");
} else {
linkName->append("s.html#");
- linkName->append(str);
+ linkName->append(std::to_string(itemPage));
}
}
- delete str;
}
fputs("<li>",output);