Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Type agnosticism, data structures and C

Name: Anonymous 2011-09-16 6:07

/prog/, I've been working on a C library with basic data structures and useful functions, and have implemented things like doubly-linked lists and vectors and so on. Now I'm working on Unicode-based string support. Here's my issue.

I've implemented type agnosticism on the vector type using void pointers (not preprocessor macros), so I want to use the vector type to represent a string. Each Unicode codepoint is an int32_t. Of course, I don't want to have to allocate four bytes on the heap for each codepoint, then point to that from each vector element; that's utterly stupid. On the other hand, doing typecasts to shove an integer in the void * type is kludgy and works very poorly, often requiring double explicit casts; once to expand/shrink the type's size, then once more to explicitly cast to a pointer or back.

How can I solve my issues and use my vector type for strings?

Name: Anonymous 2011-09-16 18:04

>>40
Why are you replying to a troll?

Name: Anonymous 2011-09-16 18:35

>>41
Why are you replying to a troll?

Name: Anonymous 2011-09-16 21:11

>>39
Thank you for proving my point, Mandarin is obviously superior.

Name: n3n7i 2011-09-16 22:05


/**
     * The number of elements memory has been allocated for.
     */

    >> intmax_t a;

    /**
     * The number of elements currently stored.
     */

    >> intmax_t l;

Will store number of elements allocated / stored in every element of the vector?

Name: n3n7i 2011-09-16 22:25

maybe something like this?

typedef struct gvector_struct {
        void **d;
        };

struct arch_gvector{
        struct gvector_struct *gVect;
        intmax_t a;
        intmax_t l;
        };

struct arch_gvector ArchVect;

//ArchVect.a = No of stored elements
//ArchVect.l = No allocated
//ArchVect->gVect[i].d = element i

Name: root@eecs.berkeley.edu 2011-09-16 22:27

>>45
No. That totally sucks. Leave the programming to the legit engineers you fucking wanna be nigger.

Name: root@eecs.berkeley.edu 2011-09-16 22:30

>>44
Will store number of elements allocated / stored in every element of the vector?

Nothing is getting stored yet because the program never completed the translation unit. Once it does, the whole thing becomes a declaration. I would say go read the ANSI/ISO C standard, but I don't think you have the mental capacity for such terse reading.

Name: n3n7i 2011-09-16 22:53

...Unless you're doing something tricky with the **void?

...you probably could've explained it by now if you weren't groaning so much..

Name: n3n7i 2011-09-16 22:56

The only reason why I'm here on a friday night, instead of going out, is that I'm a total loser in real life. I'm also broke because I got fired from nambla.org

Name: n3n7i 2011-09-16 23:06

its saturday here.... =)

Name: n3n7i 2011-09-16 23:10

So, you could just malloc a *void to a vector..??

Name: Anonymous 2011-09-17 1:01

>>51 cretin

Name: Anonymous 2011-09-17 2:17

>>52
Please try to ignore troll posts. Modify this Greasemonkey program to filter out posts by the poster n3n7i.

http://userscripts.org/scripts/show/40415

Name: n3n7i 2011-09-17 3:17

>>44
Will store number of elements allocated / stored in every element of the vector?

>>47
Nothing is getting stored yet because the program never completed the translation unit. Once it does, the whole thing becomes a declaration.

...And then..?

Name: n3n7i 2011-09-17 3:27

you do something like >>51?

=) i thought your struct was the vector... nevermind though

Name: Anonymous 2011-09-17 8:28

You need an int24_t for storing Unicode.

...or just store it all in UTF-8.

Name: Anonymous 2011-09-17 9:39

>>56

>int24_t
I think you mean int32_t.

>store it all in UTF-8.
No fucking way I'll store it in UTF-8 in memory, requiring parsing and complex processing just to traverse the codepoints.

Name: n3n7i 2011-09-17 9:52

vector.

vector vector vector!

Have you tried replacing your code with vector?

VECTOR VECTOR ÜBER ALLES

everytime i masturbate i think of vector

vector i love you don't you see

my vector is better than your vector

Name: kodak_gallery_programmer !!NOuIr5+Z3dDMZ1a 2011-09-17 10:48

>>54

It becomes a tentative definition?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List