Skip to content

Commit 792984a

Browse files
committed
COMMON: fix memory leak, fix unit path error
1 parent a67be63 commit 792984a

File tree

5 files changed

+15
-71
lines changed

5 files changed

+15
-71
lines changed

README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,6 @@ Useful adb commands for debugging:
8181
adb shell dumpsys cpuinfo
8282
adb shell top -m 10
8383

84-
## Building the TIZEN port
85-
86-
1. Download and install the Tizen IDE
87-
88-
2. Add the following lines to .bashrc
89-
```
90-
TIZEN_SDK=${HOME}/tizen-sdk
91-
TIZEN_ROOTSTRAP=${TIZEN_SDK}/platforms/mobile-3.0/rootstraps/mobile-3.0-device.native
92-
export TIZEN_BIN=${TIZEN_SDK}/tools/arm-linux-gnueabi-gcc-4.5/bin
93-
export TIZEN_LIBS=${HOME}/tizen-lib
94-
export PATH=${PATH}:${TIZEN_BIN}:~/bin
95-
export CHOST=arm-linux-gnueabi
96-
export LDFLAGS="--sysroot=${TIZEN_ROOTSTRAP} -L${TIZEN_LIBS}/lib"
97-
export CPPFLAGS="--sysroot=${TIZEN_ROOTSTRAP} -fmessage-length=0 -fPIC\
98-
-I${TIZEN_ROOTSTRAP}/usr/include -I${TIZEN_LIBS}/include"
99-
export CFLAGS=${CPPFLAGS}
100-
```
101-
3. Build the common components
102-
```
103-
./configure --enable-tizen
104-
```
105-
4. Build the project using Tizen IDE
106-
10784
### .indent.pro settings
10885
```
10986
-brf -nbap -br -brs -cdb -cdw -ce -cli0 -fca -i2 -l110 -lc110 -lp

configure.ac

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ AC_ARG_ENABLE(sdl,
3434
[ac_build_sdl="yes"],
3535
[ac_build_sdl="no"])
3636

37-
AC_ARG_ENABLE(tizen,
38-
AS_HELP_STRING([--enable-tizen],[build common library for Tizen(default=no)]),
39-
[ac_build_tizen="yes"],
40-
[ac_build_tizen="no"])
41-
4237
AC_ARG_ENABLE(android,
4338
AS_HELP_STRING([--enable-android],[build common library for Android(default=no)]),
4439
[ac_build_android="yes"],
@@ -90,9 +85,6 @@ function checkPCRE() {
9085
have_pcre="no"
9186
esac
9287

93-
if test x$ac_build_tizen = xyes; then
94-
have_pcre="no"
95-
fi
9688
if test x$ac_build_android = xyes; then
9789
have_pcre="no"
9890
fi
@@ -253,23 +245,6 @@ function buildSDL() {
253245
(cd documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)
254246
}
255247

256-
function buildTizen() {
257-
TARGET="Building common library for Tizen."
258-
259-
defaultConditionals
260-
261-
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
262-
AC_DEFINE(_TIZEN, 1, [Defined for Tizen build.])
263-
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
264-
AC_DEFINE(DEV_EVENTS_OSD, 1, [dev_events() implemented using osd_events().])
265-
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
266-
AC_DEFINE(CPU_BIGENDIAN, 1, [Tizen uses big-endian])
267-
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
268-
269-
BUILD_SUBDIRS="src/platform/tizen/common"
270-
AC_SUBST(BUILD_SUBDIRS)
271-
}
272-
273248
function buildAndroid() {
274249
TARGET="Building for Android."
275250

@@ -350,8 +325,6 @@ if test x$ac_build_fltk = xyes; then
350325
buildFLTK
351326
elif test x$ac_build_sdl = xyes; then
352327
buildSDL
353-
elif test x$ac_build_tizen = xyes; then
354-
buildTizen
355328
elif test x$ac_build_android = xyes; then
356329
buildAndroid
357330
else
@@ -378,7 +351,6 @@ src/common/Makefile
378351
src/platform/fltk/Makefile
379352
src/platform/sdl/Makefile
380353
src/platform/unix/Makefile
381-
src/platform/tizen/common/Makefile
382354
src/platform/android/Makefile
383355
])
384356
AC_OUTPUT

src/common/system.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ char *shell(const char *cmd) {
110110
return result;
111111
}
112112

113-
int dev_run(const char *src, var_t *r, int wait) {
113+
int dev_run(const char *cmd, var_t *r, int wait) {
114114
int result = 1;
115115
if (r != NULL) {
116-
char *buf = shell(src);
116+
char *buf = shell(cmd);
117117
if (buf != NULL) {
118118
r->type = V_STR;
119119
r->v.p.ptr = buf;
@@ -137,13 +137,13 @@ int dev_run(const char *src, var_t *r, int wait) {
137137
}
138138
} else {
139139
HWND hwnd = GetActiveWindow();
140-
ShellExecute(hwnd, "open", src, 0, 0, SW_SHOWNORMAL);
140+
ShellExecute(hwnd, "open", cmd, 0, 0, SW_SHOWNORMAL);
141141
}
142142
return result;
143143
}
144144

145145
#else
146-
int dev_run(const char *src, var_t *r, int wait) {
146+
int dev_run(const char *cmd, var_t *r, int wait) {
147147
int result = 1;
148148
if (r != NULL) {
149149
r->type = V_STR;
@@ -154,7 +154,7 @@ int dev_run(const char *src, var_t *r, int wait) {
154154
int bytes = 0;
155155
int total = 0;
156156
char buf[BUFSIZE + 1];
157-
FILE *fin = popen(src, "r");
157+
FILE *fin = popen(cmd, "r");
158158
if (fin) {
159159
while (!feof(fin)) {
160160
bytes = fread(buf, 1, BUFSIZE, fin);
@@ -172,18 +172,18 @@ int dev_run(const char *src, var_t *r, int wait) {
172172
result = 0;
173173
}
174174
} else if (wait) {
175-
result = (system(src) != -1);
175+
result = (system(cmd) != -1);
176176
}
177177
else if (fork() == 0) {
178178
// exec separate process
179-
int size = strlen(src) + 3;
179+
int size = strlen(cmd) + 3;
180180
char *src1 = malloc(size);
181181
if (src1 != NULL) {
182182
memset(src1, '\0', size);
183183
// double quote the command
184184
*src1 = '"';
185-
strcat(src1, src);
186-
*(src1 + strlen(src) + 1) = '"';
185+
strcat(src1, cmd);
186+
*(src1 + strlen(cmd) + 1) = '"';
187187
// -c means the next argument is the command string to execute
188188
// this allow us to execute shell script
189189
execlp("sh", "sh", "-c", src1, NULL);

src/common/units.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,14 @@ int find_unit_path(const char *name, char *file) {
6363
}
6464
}
6565

66-
// find in current directory
67-
if (access(file, R_OK) == 0) {
66+
// find in program launch directory
67+
if (gsb_bas_dir[0] && sys_search_path(gsb_bas_dir, file, file)) {
6868
return 1;
6969
}
7070

71-
// find in program launch directory
72-
if (gsb_bas_dir[0]) {
73-
strcpy(file, gsb_bas_dir);
74-
strcat(file, name);
75-
strcat(file, ".bas");
76-
77-
if (access(file, R_OK) == 0) {
78-
return 1;
79-
}
71+
// find in current directory
72+
if (sys_search_path(".", file, file)) {
73+
return 1;
8074
}
8175

8276
return 0;

src/ui/system.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ char *System::loadResource(const char *fileName) {
438438
int len = cached->length();
439439
buffer = (char *)malloc(len + 1);
440440
memcpy(buffer, cached->c_str(), len);
441+
buffer[len] = '\0';
441442
} else {
442443
int handle = 1;
443444
var_t *var_p = v_new();

0 commit comments

Comments
 (0)