Off Topic Chit Chat - (Silliness factor 5)

Hmm… btw, I have seen the chan word used for boys too , not in anime , I mean I have read some japanese stories which where written even before anime thingy , then the chan word was being used even for boys , I even used to watch some kids anime , when I was my own self a kid like this .

So I feel like it is just a wrong assumption , maybe it is just for kids in general :slightly_smiling_face:

2 Likes

You are actually correct on this.

Chan is used as well for boys. But mostly used for girls. Its not a female exclusive word tho. And actually chan is a real word its not a madeup word, if I remember correctly the “chan” word was created by kids miss pronunciation of another word. And its really used mostly by and to kids, but later used in a lot of manga and anime.

1 Like

yeaa soo…

Thankfully running the Intel 11th gen, though I’m stuck with NVIDIA. AMD though from here on out as I’ve learned AMD is more Linux and open source friendly.

1 Like

Anyone ever feels like taking a step back to bask in the glory of what they have achieved :slight_smile:. I just found about flexible array members in C. So I did the next logical step and tried to implement vectors with it.

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
  size_t size;
  size_t capacity;
  char data[]; // flexible array members
} VHeader;

typedef VHeader *Vector;

[[gnu::always_inline]]
static inline size_t vec_size(const void *data) {
  if (data == nullptr)
    return 0;
  const Vector header = (Vector)data;
  return header[-1].size;
}

[[gnu::always_inline]]
static inline size_t vec_cap(const void *data) {
  if (data == nullptr)
    return 0U;
  const Vector header = (Vector)data;
  return header[-1].capacity;
}

[[gnu::always_inline]]
static inline void *vec_new(size_t elemSiz, size_t capacity) {
  assert(capacity < UINT64_MAX);
  assert(elemSiz < UINT32_MAX / 100);

  Vector header = (Vector)malloc(elemSiz * capacity + sizeof(VHeader));
  header->capacity = capacity;
  header->size = 0U;
  return &(header[1]);
}

[[gnu::always_inline]]
static inline void vec_realloc(Vector *vec, size_t elemSiz, size_t capacity) {
  assert(capacity < UINT64_MAX);
  assert(elemSiz < UINT32_MAX / 100);

  if (vec == nullptr) {
    *vec = ((Vector)vec_new(elemSiz, capacity)) - 1;
    return;
  }

  size_t size = vec_size((*vec)->data);

  if (vec_cap((*vec)->data) < capacity) {
    *vec = (Vector)realloc(*vec, elemSiz * capacity + sizeof(VHeader));
    (*vec)->capacity = capacity;
    (*vec)->size = size;
  }
}

[[gnu::always_inline]]
static inline void *vec_expand(void *data, size_t elemSiz) {
  Vector header = nullptr;
  if (data == nullptr) {
    header = ((Vector)vec_new(elemSiz, 8)) - 1;
  } else {
    header = ((Vector)data) - 1;
  }

  if (header->size == header->capacity) {
    vec_realloc(&header, elemSiz, header->capacity << 1U);
  }
  header->size++;
  return &(header[1]);
}

#define vec_push_back(vec_, value_)                                            \
  {                                                                            \
    void *_tmp_ = vec_expand((vec_), sizeof(*(vec_)));                         \
    (vec_) = (typeof(vec_))(_tmp_);                                            \
    (vec_)[vec_size(vec_) - 1] = value_;                                       \
  }

#define vec_dealloc(vec_)                                                      \
  {                                                                            \
    Vector _tmp_ = ((Vector)vec) - 1;                                          \
    free(_tmp_);                                                               \
    _tmp_ = nullptr;                                                           \
    vec_ = nullptr;                                                            \
  }

#define vec_back(vec_) (vec_[vec_size(vec_) - 1])
#define vec_front(vec_) (vec_[0])
#define vec_empty(vec_) (vec_size(vec_) == 0)
#define vec_max_size UINT64_MAX

#define vec_reserve(vec_, cap_)                                                \
  {                                                                            \
    if (vec_ == nullptr)                                                       \
      vec_ = (typeof(vec_))vec_new(sizeof(*(vec_)), (cap_));                   \
    else {                                                                     \
      Vector _tmp_ = ((Vector)vec_) - 1;                                       \
      vec_realloc(&_tmp_, sizeof(*(vec_)), cap_);                              \
    }                                                                          \
  }

#define vec_insert_at(vec_, pos_, data_)                                       \
  {                                                                            \
    if (pos_ >= 0U) {                                                          \
      void *_tmp_ = vec_expand((vec_), sizeof(*(vec_)));                       \
      (vec_) = (typeof(vec_))(_tmp_);                                          \
      size_t bkIdx = vec_size(vec_) - 1;                                       \
      for (; bkIdx > pos_; bkIdx--) {                                          \
        (vec_)[bkIdx] = (vec_)[bkIdx - 1];                                     \
      }                                                                        \
      (vec_)[pos_] = data_;                                                    \
    }                                                                          \
  }

int main(void) {
  // Create a vector
  double *vec = nullptr;
  vec_reserve(vec, 22);

  // store data in vector
  for (size_t i = 0; i < 10; ++i) {
    vec_push_back(vec, i * 0.05);
  }

  // print it
  size_t size = vec_size(vec);
  for (size_t i = 0; i < size; ++i) {
    printf("Value at index %zu: %f\n", i, vec[i]);
  }
  printf("Vector size: %zu\n", size);

  for (size_t i = 9; i < 20; ++i) {
    vec_push_back(vec, i);
  }

  vec_insert_at(vec, 10, -100.0008);
  size = vec_size(vec);
  for (size_t i = 0; i < size; ++i) {
    printf("Value at index %zu: %f\n", i, vec[i]);
  }

  vec_insert_at(vec, 0, -10.8);

  printf("Vector size: %zu\n", vec_size(vec));
  printf("Vector capacity: %zu\n", vec_cap(vec));
  printf("with first %f and last %f elements respectively\n", vec_front(vec),
         vec_back(vec));

  // dealloc vec! manage your memory :)
  vec_dealloc(vec);
  return 0;
}

For anyone wondering you need to enable c23 to compile this.
I know ppl have already done this and its reinventing the wheel but I don’t care. :slight_smile:

2 Likes

I know all the things that you have used in this but definitely need to scratch my head a lot to get to your thinking/understanding level :slightly_smiling_face:

1 Like

Is it weird that I find flatpak better than snap same way I feel podman is better than docker?

Only if you run 'buntu. :slight_smile:

3 Likes

:joy: :joy: Never loved 'buntu

1 Like

Hmm… just noticed that I am no more regular. My trust level is now as a member .

Strange because I haven’t been away from garuda forum :eyes:

PS: it is something like 5th time that I have fallen back to member, Lol :stuck_out_tongue:

Read more in forum :smiley:

Ankur - Requirements for Trust Level 3

In the last 100 days:

Value Requirement
Posts Read 1935 2147
2 Likes

depends on which DE you are using :eyes:

1 Like

Has anyone got their head around the cosmic config files lol?

4 Likes

I would have to admit that it looks so clean :eyes:

1 Like

You talking about desktop/UI?
Its really clean and fairly customizable (don’t compare with KDE). It does feel knda limiting at some things though, like almost no config files as of now, click-to-focus shi… etc.

Whatever, it still looks good

I am not obsessed with config files if it is DE but obsessed only if it is WM :slightly_smiling_face:

Is that the Pop! alpha or the AUR pkgs?

1 Like

AUR, while I certainly love hopping between DEs/WMs, I’m never leaving garuda for that! :grin:

4 Likes

Brought up a couple issues to Carl (CEO), like a GUI for adding/removing additional panels, and moving window buttons to the left side of the application, and he told me that there are no plans to ever implement those two features. :frowning: Which really sucks because I’m so used to left side window buttons and if they’re trying to make it appear a “very customizable desktop”, you would think adding/removing additional panels would be a step in the right direction…

Maybe he was talking in terms of the Alphas, but still, two let-downs if you ask me.

1 Like

What about me?