Skip to content

Commit e1f3aae

Browse files
committed
examples/htmltitle: use C++ casts between pointer types
Compilers and static analyzers warn about using C-style casts here. Closes curl#3975
1 parent 992083b commit e1f3aae

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/examples/htmltitle.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ static void StartElement(void *voidContext,
136136
const xmlChar *name,
137137
const xmlChar **attributes)
138138
{
139-
Context *context = (Context *)voidContext;
139+
Context *context = static_cast<Context *>(voidContext);
140140

141-
if(COMPARE((char *)name, "TITLE")) {
141+
if(COMPARE(reinterpret_cast<char *>(name), "TITLE")) {
142142
context->title = "";
143143
context->addTitle = true;
144144
}
@@ -152,9 +152,9 @@ static void StartElement(void *voidContext,
152152
static void EndElement(void *voidContext,
153153
const xmlChar *name)
154154
{
155-
Context *context = (Context *)voidContext;
155+
Context *context = static_cast<Context *>(voidContext);
156156

157-
if(COMPARE((char *)name, "TITLE"))
157+
if(COMPARE(reinterpret_cast<char *>(name), "TITLE"))
158158
context->addTitle = false;
159159
}
160160

@@ -167,7 +167,7 @@ static void handleCharacters(Context *context,
167167
int length)
168168
{
169169
if(context->addTitle)
170-
context->title.append((char *)chars, length);
170+
context->title.append(reinterpret_cast<char *>(chars), length);
171171
}
172172

173173
//
@@ -178,7 +178,7 @@ static void Characters(void *voidContext,
178178
const xmlChar *chars,
179179
int length)
180180
{
181-
Context *context = (Context *)voidContext;
181+
Context *context = static_cast<Context *>(voidContext);
182182

183183
handleCharacters(context, chars, length);
184184
}
@@ -191,7 +191,7 @@ static void cdata(void *voidContext,
191191
const xmlChar *chars,
192192
int length)
193193
{
194-
Context *context = (Context *)voidContext;
194+
Context *context = static_cast<Context *>(voidContext);
195195

196196
handleCharacters(context, chars, length);
197197
}

0 commit comments

Comments
 (0)