
Kiana Khansmith
NASA
★
Cosmic Funnies
EXPECTATIONS
Xuebing Du

blake kathryn

ellievsbear

@theartofmadeline


h
Fai_Ryy
cherry valley forever
Doug Jones
Show & Tell

izzy's playlists!
let's talk about Bridgerton tea, my ask is open

tannertan36
seen from Russia
seen from Romania
seen from United States
seen from Colombia
seen from Belarus
seen from South Africa

seen from Iraq
seen from United States
seen from United States

seen from United States

seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United Kingdom
seen from Mexico

seen from France
seen from United Kingdom
@redahe

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Share if your first IDE was blue
Polymorphism in C
In practice there are not so many cases than we have objects with a linear heirarhcy. (More offten we need a set of features in an object and a concept of some class-labels or categories, like Interfaces in Java). But when we actually have a logical inheritance than we want a polymorphism and when object have only single parent - we can achieve polymorphism in pure C without OOP abstractions and compile-time overhead:
typedef struct phys_object_t phys; ..... } character_t; typedef struct { character_t chr; int exp; int score; ...... } player_t; //method void character_jump(character_t* chr){ chr->phys.momentum.y = 10; } // instance player_t player; //invoke character_jump((character_t*)(&player));
Here player is a subclass of a character. And each character can jump so object of type player can jump too. It works because both structs have same offset for the common field ‘phys’. This achieved by placing parent’s data in the first field of player_t and just simple type-cast.
Write in C. Have fun and stay efficient.
Dynamic arrays in C
When you need dynamic arrays - high-level languages would offer you containers. With that containers you would have overhead on object’s header, dependency on standard lib and most important you will lose control of you memory consumption.
In C - I just write simple macro-functions: First is for array creation. Second is for adding element and auto-resizing.
#include <stdlib.h> #define d_array(t, count, size) ({\ size = 32;\ count = 0;\ (t*)malloc(sizeof(t)*size);\ }) #define push_back(t, arr, elem, count, size) ({\ if (count >= size) {size = size * 2;\ arr = (t*)realloc(arr, sizeof(t)*size);} \ arr[count++] = elem;\ })
As result I have vanilla array, capable to grow. I don’t need to keep size of an array in a heap, if I know that it will not grow after initialization. I even don’t need to keep current count in a heap, if I have indices stored in another array.
You can easily change the logic of this macros, for example, you know that the size of an array never exceed 1200, you can add this restriction in push_back macro, and your arrays size will not grow from 1024 to 2048 (as I it would happen with high-level containers).
Stay efficient, write in C!
My current desktop

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
HOWTO: Usenet & Fidonet with slrn
The year 2016.
Terminal programs are still efficient fast and widely used. Text editors are still more convenient than text-areas in browsers. Advertising - is still annoying. Most social platforms still don't support quoting or they do it a wrong way. So, for vaporwave-gifs and blogging - Tumblr is a no-brainer, but for online discussions - the old good Usenet is the best platform, imo.
This post is my step-by-step instruction how to configure and run the slrn -a lightweight text-mode NNTP client on Linux.