commit f89bcd2
chld
·
2026-07-21 20:26:07 +0000 UTC
parent 652a9cd
code cleanup
2 files changed,
+5,
-9
+4,
-5
1@@ -5,7 +5,6 @@
2
3 #include "cottonwindow.h"
4
5-// hello
6
7 class View:public BView
8 {
9@@ -44,12 +43,12 @@ public:App(BRect r, const char *title, int texture_w, int texture_h):BApplicatio
10 };
11
12 static App *_app=nullptr;
13-static sem_id g_ready_sem = -1;
14+static sem_id sem = -1;
15
16 int cottonwindow_init(CottonWindow *cw, const char *title, int window_w, int window_h, int texture_w, int texture_h)
17 {
18 (void)cw;
19- g_ready_sem = create_sem(0, "r");
20+ sem = create_sem(0, "r");
21
22 struct InitData { const char *title; int ww, wh, tw, th; };
23 struct InitData d{title, window_w, window_h,texture_w, texture_h};
24@@ -57,12 +56,12 @@ int cottonwindow_init(CottonWindow *cw, const char *title, int window_w, int win
25 thread_id id=spawn_thread([](void *data) -> status_t{
26 InitData *d = (InitData*)data;
27 _app=new App(BRect(100, 100, 100 + d->ww, 100 + d->wh), d->title, d->tw, d->th);
28- release_sem(g_ready_sem);
29+ release_sem(sem);
30 _app->Run();
31 return 0;
32 }, "cotton", B_NORMAL_PRIORITY, &d);
33 resume_thread(id);
34- acquire_sem(g_ready_sem);
35+ acquire_sem(sem);
36
37 return 0;
38 }
+1,
-4
1@@ -12,15 +12,12 @@ int main(int argc, char **argv)
2 return 1;
3 }
4
5- printf("hello world");
6-
7 CottonWindow cw;
8
9- cottonwindow_init(&cw, "cotton", VIDEO_WIDTH*2, VIDEO_HEIGHT*2, VIDEO_WIDTH, VIDEO_HEIGHT))
10+ cottonwindow_init(&cw, "cotton", VIDEO_WIDTH*2, VIDEO_HEIGHT*2, VIDEO_WIDTH, VIDEO_HEIGHT);
11
12 Cotton cotton;
13 cotton_init(&cotton);
14- printf("crashec");
15
16 FILE *file = fopen(argv[1], "r");
17 if (!file)