Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2253816

Browse files
(c++)++
1 parentdfcc968 commit2253816

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

‎libwaffleizer.cpp‎

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,22 @@ wflShiftDouble(wflBlobDsc* blob)
9191
return res;
9292
}
9393

94-
char *
94+
std::string
9595
wflShiftPgPoint(wflBlobDsc* blob)
9696
{
97-
char buf[10000];
98-
int ret, length;
99-
char *res;
97+
std::string res ="";
10098
char *a1, *a2;
10199

102100
a1 =wflShiftDouble(blob);
103-
if (! a1)returnNULL;
101+
if (! a1)returnres;
104102

105103
a2 =wflShiftDouble(blob);
106104
if (! a2)
107105
{
108106
wflFree(blob->mctx, a1);
109-
returnNULL;
107+
returnres;
110108
}
111-
ret =snprintf(buf,10000,"(%s, %s)",a1, a2);
112-
// FIXME анализировать ret
113-
114-
length =strlen(buf);
115-
res = (char*)wflMalloc(blob->mctx,length+1);
116-
memcpy(res,buf,length +1);
117-
wflFree(blob->mctx, a1);
118-
wflFree(blob->mctx, a2);
119-
109+
res = (std::string)"(" + a1 +"," + a2 +")";
120110
return res;
121111
}
122112

@@ -125,13 +115,15 @@ std::string
125115
wflShiftPgPath(wflBlobDsc* blob)
126116
{
127117
std::string res ="";
128-
char *pc;
118+
std::string point;
129119

130-
while (pc =wflShiftPgPoint(blob))
120+
while (1)
131121
{
122+
point =wflShiftPgPoint(blob);
123+
if (point.empty())
124+
break;
132125
if (!res.empty()) res = res +",";
133-
res = res + pc;
134-
wflFree(blob->mctx, pc);
126+
res = res + point;
135127
}
136128
if (res.empty())
137129
return res;
@@ -148,9 +140,8 @@ poly_contain_prepare(char* in, int in_size, char ** res1, char ** res2)
148140
wflMemCtx * mctx;
149141
wflBlobDsc blob;
150142
wflBlobDsc * b2;
151-
char *r1;
152143

153-
std::string r2;
144+
std::stringr1,r2;
154145

155146
mctx =wflCreateMemCtx();
156147

@@ -162,23 +153,22 @@ poly_contain_prepare(char* in, int in_size, char ** res1, char ** res2)
162153

163154
r1 =wflShiftPgPoint(&blob);
164155

165-
if (! r1)
156+
if (r1.empty())
166157
{
167158
fprintf(stderr,"Problema\n");
168159
return1;
169160
}
170-
161+
171162
r2 =wflShiftPgPath(& blob);
172163

173164
if (r2.empty())
174165
{
175166
fprintf(stderr,"Problema\n");
176167
return1;
177168
}
178-
179-
*res1 = (char *)malloc(strlen(r1)+1);
180-
memcpy(*res1, r1,strlen(r1) +1);
181-
free(r1);
169+
170+
*res1 = (char *)malloc(strlen(r1.c_str()) +1);
171+
memcpy(*res1, r1.c_str(),strlen(r1.c_str()) +1);
182172

183173
*res2 = (char *)malloc(strlen(r2.c_str())+1);
184174
memcpy(*res2, r2.c_str(),strlen(r2.c_str()) +1);

‎libwaffleizer.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ void wflFree(wflMemCtx * mctx, void* ptr);
2525

2626
wflBlobDsc*wflShiftN(wflBlobDsc* blob,size_t n);
2727
char *wflShiftDouble(wflBlobDsc* blob);
28-
char *wflShiftPgPoint(wflBlobDsc* blob);
29-
std::stringwflShiftPgPath(wflBlobDsc* blob);
28+
std::stringwflShiftPgPoint(wflBlobDsc* blob);
29+
std::stringwflShiftPgPath(wflBlobDsc* blob);
3030

3131

3232

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp