Skip to content

Commit

Permalink
fix for new c version
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Feb 20, 2024
1 parent 45798c6 commit 0f10921
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion base_pack/doom/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ App(
fap_category="Games",
fap_icon_assets="assets",
fap_author="@xMasterX & @Svarich & @hedger (original code by @p4nic4ttack)",
fap_version="1.2",
fap_version="1.3",
fap_description="Will it run Doom?",
)
2 changes: 1 addition & 1 deletion base_pack/doom/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define bmp_font_width_pxs 192
#define bmp_font_height_pxs 48
#define CHAR_MAP " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.,-_(){}[]#"
#define CHAR_WIDTH 4
#define UICHAR_WIDTH 4
#define CHAR_HEIGHT 6

#define BMP_GUN_WIDTH 32
Expand Down
2 changes: 1 addition & 1 deletion base_pack/doom/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void drawTextSpace(int8_t x, int8_t y, char* txt, uint8_t space, Canvas* const c
while((ch = txt[i]) != '\0') {
drawChar(pos, y, ch, canvas);
i++;
pos += CHAR_WIDTH + space;
pos += UICHAR_WIDTH + space;

// shortcut on end of screen
if(pos > SCREEN_WIDTH) return;
Expand Down
4 changes: 2 additions & 2 deletions base_pack/unitemp/Sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,14 @@ Sensor* unitemp_sensor_alloc(char* name, const SensorType* type, char* args) {
Sensor* sensor = malloc(sizeof(Sensor));
if(sensor == NULL) {
FURI_LOG_E(APP_NAME, "Sensor %s allocation error", name);
return false;
return NULL;
}

//Выделение памяти под имя
sensor->name = malloc(11);
if(sensor->name == NULL) {
FURI_LOG_E(APP_NAME, "Sensor %s name allocation error", name);
return false;
return NULL;
}
//Запись имени датчка
strcpy(sensor->name, name);
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/FlipBIP/lib/crypto/base32.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ char* base32_encode(
int ret = base32_encode_character(out[i], alphabet);

if(ret == -1) {
return false;
return NULL;
} else {
out[i] = ret;
}
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/air_mouse_ofw/air_mouse_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define TAG "SensorModule"

#define BLE_HID_KEYS_PATH "/ext/apps_data/hid_ble/.bt_hid.keys"
#define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys"

typedef struct {
Gui* gui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#define WIDGET_WIDTH 126
#define WIDGET_HEIGHT 64
#define CHAR_WIDTH 1
#define UICHAR_WIDTH 1

#endif // CONSTANTS_H
42 changes: 21 additions & 21 deletions non_catalog_apps/crypto_dictionary_book/scenes/scenes.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ char* wrap_text(const char* text, size_t max_line_width) {
// More realistic initial size estimation
size_t allocated_size = len + len / max_line_width + 1;
char* wrapped = malloc(allocated_size);
if (!wrapped) return NULL;
if(!wrapped) return NULL;

size_t cur_line_len = 0;
size_t wrapped_index = 0;
size_t word_len = 0;

for (size_t i = 0; i < len; ++i) {
for(size_t i = 0; i < len; ++i) {
word_len++;
if (text[i] == '\n') {
for (size_t j = i - word_len + 1; j <= i; ++j) {
if(text[i] == '\n') {
for(size_t j = i - word_len + 1; j <= i; ++j) {
// Check and reallocate if necessary before writing to the buffer
if (wrapped_index >= allocated_size) {
if(wrapped_index >= allocated_size) {
allocated_size *= 2;
char* new_wrapped = realloc(wrapped, allocated_size);
if (!new_wrapped) {
if(!new_wrapped) {
free(wrapped);
return NULL;
}
Expand All @@ -97,41 +97,41 @@ char* wrap_text(const char* text, size_t max_line_width) {
continue;
}

if (text[i] == ' ' || i == len - 1) {
if (word_len >= max_line_width) {
if (cur_line_len > 0) {
if(text[i] == ' ' || i == len - 1) {
if(word_len >= max_line_width) {
if(cur_line_len > 0) {
wrapped[wrapped_index++] = '\n';
cur_line_len = 0;
}
for (size_t j = i - word_len + 1; j <= i; ++j) {
for(size_t j = i - word_len + 1; j <= i; ++j) {
// Check and reallocate if necessary before writing to the buffer
if (wrapped_index >= allocated_size) {
if(wrapped_index >= allocated_size) {
allocated_size *= 2;
char* new_wrapped = realloc(wrapped, allocated_size);
if (!new_wrapped) {
if(!new_wrapped) {
free(wrapped);
return NULL;
}
wrapped = new_wrapped;
}
wrapped[wrapped_index++] = text[j];
if (++cur_line_len >= max_line_width && text[j] != '\n') {
if(++cur_line_len >= max_line_width && text[j] != '\n') {
wrapped[wrapped_index++] = '\n';
cur_line_len = 0;
}
}
} else if (cur_line_len + word_len > max_line_width) {
if (cur_line_len > 0) {
} else if(cur_line_len + word_len > max_line_width) {
if(cur_line_len > 0) {
wrapped[wrapped_index++] = '\n';
cur_line_len = 0;
}
}
for (size_t j = i - word_len + 1; j <= i; ++j) {
for(size_t j = i - word_len + 1; j <= i; ++j) {
// Check and reallocate if necessary before writing to the buffer
if (wrapped_index >= allocated_size) {
if(wrapped_index >= allocated_size) {
allocated_size *= 2;
char* new_wrapped = realloc(wrapped, allocated_size);
if (!new_wrapped) {
if(!new_wrapped) {
free(wrapped);
return NULL;
}
Expand All @@ -148,7 +148,6 @@ char* wrap_text(const char* text, size_t max_line_width) {
return wrapped;
}


void topic_scene_on_enter(void* context) {
furi_assert(context);
App* app = (App*)context;
Expand All @@ -162,13 +161,14 @@ void topic_scene_on_enter(void* context) {
if(file_stream_open(app->file_stream, file_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
FuriString* line = furi_string_alloc();
while(stream_read_line(app->file_stream, line)) {
dynamic_buffer_append(&dynamic_content, furi_string_get_cstr(line), furi_string_size(line));
dynamic_buffer_append(
&dynamic_content, furi_string_get_cstr(line), furi_string_size(line));
dynamic_buffer_append(&dynamic_content, "\r\n", 1);
}
dynamic_buffer_append(&dynamic_content, "\0", 1);
furi_string_free(line);
file_stream_close(app->file_stream);
size_t max_line_width = WIDGET_WIDTH / CHAR_WIDTH;
size_t max_line_width = WIDGET_WIDTH / UICHAR_WIDTH;
char* wrapped_text = wrap_text(dynamic_content.data, max_line_width);
dynamic_buffer_free(&dynamic_content);

Expand Down
3 changes: 2 additions & 1 deletion non_catalog_apps/hid_file_transfer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ static void dispatch_view(void* contextd, uint32_t index) {
}
}

bool eventCallback() {
static bool eventCallback(void* context) {
UNUSED(context);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#define WIDGET_WIDTH 128
#define WIDGET_HEIGHT 64
#define CHAR_WIDTH 5
#define UICHAR_WIDTH 5

#endif // CONSTANTS_H
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ void topic_scene_on_enter(void* context) {
if(file_stream_open(app->file_stream, file_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
FuriString* line = furi_string_alloc();
while(stream_read_line(app->file_stream, line)) {
dynamic_buffer_append(&dynamic_content, furi_string_get_cstr(line), furi_string_size(line));
dynamic_buffer_append(
&dynamic_content, furi_string_get_cstr(line), furi_string_size(line));
dynamic_buffer_append(&dynamic_content, "\r\n", 1);
}
dynamic_buffer_append(&dynamic_content, "\0", 1);
furi_string_free(line);
file_stream_close(app->file_stream);
size_t max_line_width = WIDGET_WIDTH / CHAR_WIDTH;
size_t max_line_width = WIDGET_WIDTH / UICHAR_WIDTH;
char* wrapped_text = wrap_text(dynamic_content.data, max_line_width);
dynamic_buffer_free(&dynamic_content);

Expand Down

0 comments on commit 0f10921

Please sign in to comment.