Changeset 690ad20 in mainline for uspace/app/kio/kio.c


Ignore:
Timestamp:
2025-04-17T15:29:16Z (5 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
39e1b9a
Parents:
d5b37b6
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-11 20:06:16)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 15:29:16)
Message:

Convert kio buffer to bytes (part 1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/kio/kio.c

    rd5b37b6 r690ad20  
    5959typedef struct {
    6060        link_t link;
    61         size_t length;
    62         char32_t *data;
     61        size_t bytes;
     62        char *data;
    6363} item_t;
    6464
     
    6868static FIBRIL_MUTEX_INITIALIZE(mtx);
    6969
    70 #define READ_BUFFER_SIZE (PAGE_SIZE / sizeof(char32_t))
     70#define READ_BUFFER_SIZE PAGE_SIZE
    7171
    7272static size_t current_at;
    73 static char32_t read_buffer[READ_BUFFER_SIZE];
     73static char read_buffer[READ_BUFFER_SIZE];
    7474
    7575/** Klog producer
     
    8282 *
    8383 */
    84 static void producer(size_t length, char32_t *data)
    85 {
    86         item_t *item = (item_t *) malloc(sizeof(item_t));
     84static void producer(size_t bytes, char *data)
     85{
     86        item_t *item = malloc(sizeof(item_t));
    8787        if (item == NULL)
    8888                return;
    8989
    90         size_t sz = sizeof(char32_t) * length;
    91         char32_t *buf = (char32_t *) malloc(sz);
    92         if (buf == NULL) {
     90        item->bytes = bytes;
     91        item->data = malloc(bytes);
     92        if (!item->data) {
    9393                free(item);
    9494                return;
    9595        }
    9696
    97         memcpy(buf, data, sz);
     97        memcpy(item->data, data, bytes);
    9898
    9999        link_initialize(&item->link);
    100         item->length = length;
    101         item->data = buf;
    102100        prodcons_produce(&pc, &item->link);
    103101}
     
    125123                item_t *item = list_get_instance(link, item_t, link);
    126124
    127                 for (size_t i = 0; i < item->length; i++)
    128                         putuchar(item->data[i]);
    129 
    130                 if (log != NULL) {
    131                         for (size_t i = 0; i < item->length; i++)
    132                                 fputuc(item->data[i], log);
    133 
     125                fwrite(item->data, 1, item->bytes, stdout);
     126
     127                if (log) {
     128                        fwrite(item->data, 1, item->bytes, log);
    134129                        fflush(log);
    135130                        vfs_sync(fileno(log));
Note: See TracChangeset for help on using the changeset viewer.