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

libgeneralist

Name: Anonymous 2011-09-12 22:56

So, /prog/, I'm writing a general library in C, with the aim of being somewhat inspired by libraries such as glib, but far lighter and cleaner. So far, I have a linked list implementation and a Unicode string implementation (this is incomplete), totalling 670 SLOC. The build system is cmake, the code is fully documented with doxygen. Of course, the library is in its infancy and far from finished; what other things should I implement? Any data structures? OS abstractions?

Name: Anonymous 2011-09-13 10:29

ooc already has you beat by miles.

Name: Anonymous 2011-09-13 15:17

>>28
use keys that aren't numbers. They are just better.

hints you shouldn't be using a number for something: adding two of them doesn't make sense and is not useful.

Name: Anonymous 2011-09-13 15:33

[m]nice dubz >>44[m]

Name: Anonymous 2011-09-13 17:55

<--- Two unique digits

Name: Anonymous 2011-09-13 19:43

Goats in hats get

Name: n3n7i 2011-09-13 21:22

>>42
...Care to explain? I can't see how i'd use anything else..
Yeah adding two keys doesn't make a lot of sense...
Being able to increment a key with X+=1; is kind of nice though...

Name: Anonymous 2011-09-13 22:04

>>46
cretin

Name: n3n7i 2011-09-13 22:21

Eg. Using an array of structs to store chars..


aStruct[1].ID = 1, aStruct[1].Index = 1, aStruct[1].Val="A"
aStruct[2].ID = 2, aStruct[2].Index = 2, aStruct[2].Val="B"
aStruct[3].ID = 3, aStruct[3].Index = 3, aStruct[3].Val="C"
aStruct[4].ID = 4, aStruct[4].Index = 4, aStruct[4].Val="D"

A=Id-1 // B=2 / C=3 ... 

reSort?
aStruct[1].ID = 3, aStruct[1].Index = 3, aStruct[1].Val="C"
aStruct[2].ID = 4, aStruct[2].Index = 4, aStruct[2].Val="D"
aStruct[3].ID = 1, aStruct[3].Index = 1, aStruct[3].Val="A"
aStruct[4].ID = 2, aStruct[4].Index = 2, aStruct[4].Val="B"

A still equals Id-1 // B=2 / C=3 ...?

Name: n3n7i 2011-09-14 0:47

Probably another bad example... reSort #2?

aStruct[1].ID = 2, aStruct[1].Index = 4, aStruct[1].Val="B"
aStruct[2].ID = 3, aStruct[2].Index = 1, aStruct[2].Val="C"
aStruct[3].ID = 4, aStruct[3].Index = 2, aStruct[3].Val="D"
aStruct[4].ID = 1, aStruct[4].Index = 3, aStruct[4].Val="A"

Name: Anonymous 2011-09-14 0:47

>>48
>>49
ITT: offtopic bullshit

Name: Sussex Dev Team 2011-09-14 2:02

>>46,48-49
Please stop decreasing the average quality of posts where the name field is equal to the string "n3n7i".

Thank you.

Name: n3n7i 2011-09-14 3:29

>>50 Technically, you could just about call it a linked list?
Except index isn't actually linked to the record it resides in...
It could easily be turned into a linked version though?

Name: Anonymous 2011-09-14 3:38

n3n7i is trying so hard, it's adorable

Name: n3n7i 2011-09-14 3:40

if Index is taken to represent a Next pointer

aStruct[1].Value = "B" // .Next = 4

aStruct[4].Value = "A" // .Next = 3

aStruct[3].Value = "D" // .Next = 2

aStruct[2].Value = "C" // .Next = 1 (Loop?)

...Sorted without even moving the array entries?
...Its a linked list Array =)

Name: Anonymous 2011-09-14 4:31

>>52
>>54
Get the fuck out of my thread.

Name: Sussex Dev Team 2011-09-14 6:09

>>52,54
Please stop decreasing the average quality of posts where the name field is equal to the string "n3n7i".

Thank you.

Name: n3n7i 2011-09-14 6:37

>>53 == >>55 ? ^^

Name: Anonymous 2011-09-14 7:57

Hey guys what goinOh... Carry on then

Name: n3n7i 2011-09-14 20:48

>>55
....Sooo are you going to post something..? ...Else

hey >>58, sup?

Name: n3n7i 2011-09-15 3:41

>>1 No linked array-struct [L.a.st.]?

...also, don't you have to free each item seperately in a linked list?

Name: Anonymous 2011-09-15 3:59

>>60
Could you rephrase your questions? I don't understand them.

Name: Anonymous 2011-09-15 7:16

>>60
I think your searching for dicks¿ =)

Name: Anonymous 2011-09-15 15:08

>>62
your searching

What about my searching for dicks?

Name: n3n7i 2011-09-15 16:53

...heeheeheee =)
You can use Tries =) =)
... heehee =)

Name: n3n7i 2011-09-15 20:51

...Just for you >>n64
//-------------

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//-----------------------------

const char cBlock[30] ={"!abcdefghijklmnopqrstuvwxyz?"};

struct s_chNode{int ID, Index, PreVal, Value, Branch, Leaf;};

struct s_chNode *Blinks, *blink;

int iBlinkmax=0, iBlinks=0;

//-----------------------------

void initBlink(){
Blinks = (struct s_chNode *)malloc(sizeof(struct s_chNode));
}

//------------------------------

void incBlink(){
blink = realloc(Blinks,((iBlinkmax+=10)+2)* sizeof(struct s_chNode));
if (blink!=NULL) Blinks = blink;
}

//------------------

int BlinkScan(int BPreV, int BVal){
int iB, iHalt=-1;
for(iB=0;iB<iBlinks;iB++){
    if(Blinks[iB].Value == BVal)
        if(Blinks[iB].PreVal == BPreV) return iB;
    }
return -1;
}

//-----------------------
   
int BlinkEntry(int iD, int PreVal, int Val){
int iB=0;
iB = BlinkScan(PreVal, Val);
  if (iB!=-1) return iB;
if(iBlinkmax<=iD) incBlink();
Blinks[iD].ID = iD;
Blinks[iD].Index = 0;
Blinks[iD].PreVal = PreVal;
Blinks[iD].Value = Val;
Blinks[iD].Branch = 0;
Blinks[iD].Leaf = 0;
iBlinks++;
//printf("added %i", iBoards-1);
return iD;
}

//------------------

int AutoBlinkScan(int BPreV, int BVal){
int iB, iHalt=-1, BVMin = BVal;
for(iB=0;iB<iBlinks;iB++){
    if(Blinks[iB].PreVal == BPreV)
        if(Blinks[iB].Value <= BVMin){
            iHalt = iB;
            BVMin = Blinks[iB].Value;
            }
    }
return iHalt;
}

//----------------------------------

void BlinkSort(int Zion){
int i, ii, iZ, Zi, bspv, bsnv;
Zi=Zion;
bspv = Blinks[Zi].PreVal;
bsnv = Blinks[Zi].Value;
for(i=1;i<27;i++){
    iZ = BlinkScan(bspv, i);
    ii = AutoBlinkScan(i, 0);
    if(iZ!=-1){
        Blinks[Zi].Branch = iZ;
        Blinks[iZ].Leaf = ii;
        printf("%i - %i / %i\n", Zi, iZ, ii);
        Zi = iZ;
        }   
    }
}

//-----------------------------------

int GetLeaf(int ZionII){
int Zi;
Zi=ZionII;
while((Blinks[Zi].Leaf==0)+(Blinks[Zi].Branch!=0)==2){
    Zi = Blinks[Zi].Branch;
    }
return Zi;
}

//---------------------------

int scanChar(int cX){
  int Geti=0;
  while(Geti<=27){
    if((int) cBlock[Geti]==cX) return Geti;
    Geti++;
    }
  return 0;
}

//------------------------------

int main(int argc, char *argv[]){
  char  myStr[1000];
  int i=0, j=1, k=0, l=0, m=0, loopi=0, li=0;

  initBlink();
  BlinkEntry(iBlinks, 0, 0);

  if(argc>=1){
    loopi = strlen(argv[1]);
    for(li=0;li<loopi;li++){
        myStr[li] = argv[1][li];
        }
    } else {
    loopi=10;
    scanf("%10s", myStr);
    }
  while(((int) j!=0)+(i<loopi)==2){
    j= (int) myStr[i];
    printf("-%c -", j);
    k=scanChar(j);
    m=BlinkEntry(iBlinks, l, k);
    printf("%c-%c-%i-%i\n", cBlock[l], cBlock[k], m, i);
    l=k;
    i++;
    }
  BlinkSort(0);
  printf("\n");
  li=GetLeaf(0);
  while(Blinks[li].Branch>0){
    if(Blinks[li].Leaf>0){
        printf("\nli %i, leaf %i\n", li, Blinks[li].Leaf);
        BlinkSort(Blinks[li].Leaf);
        }
    if(Blinks[li].Branch>0) {
        li=GetLeaf(Blinks[li].Branch);
        }
    }
  printf("leaf %i\n", li);

  if(Blinks[li].Leaf>0){
    printf("\nli %i, leaf %i\n", li, Blinks[li].Leaf);
    BlinkSort(Blinks[li].Leaf);
    }

  /*BlinkSort(6);
  printf("\n");
  BlinkSort(17);
  printf("\n");
  BlinkSort(44);
  printf("\n");
  BlinkSort(33);
  printf("\n");
*/
  return 0;
}

//--------------

Name: n3n7i 2011-09-15 22:07

>>61
My bad... i probably don't know enough about making lib's...

So, if you have a linked list implementation, you call a function and it returns a linked list...?

Name: n3n7i 2011-09-15 22:31

Seems simple enough...

How could I build structures on-the-fly..?

Name: tdavis 2011-09-15 22:35

I want to stick my balls inside your rectum, n3n7i.

Name: n3n7i 2011-09-15 22:57

>>68 Anonymous grade wit...
 
...This may be useful >> ? Co-ordinate systems in databases??

Eg. you use two ints to locate an entry, with one representing the TABLE!, and the other the position in that table?

Name: n3n7i 2011-09-15 23:13

=) ... hee hee =)
... Or I could use tries >> ? Then build an IA =)
... heeheehee =) play chess >> though? with Tries? ...
... like n=b >> b<n =)

Name: n3n7i 2011-09-15 23:19

... Sorry my bad, not Tries... Mean hash >> hash tables? =)
Or ... Just linked list for index, ...? =)
indexes with >> linked list
... Might try some libs ... =)
... heehee =)

Name: Anonymous 2011-09-15 23:47

>>70,71 kill yourself, heehee =)

Name: Anonymous 2011-09-16 2:24

no one fucking cares heehee

Name: n3n7i 2011-09-16 3:08

>>65 + >>69 should be enough for a basic word-store, at least

//to clarify; how do i 'Define' a structure-variant on the fly, malloc-ing a hard-coded struct definition is no trouble, but can I 'soft-code' a struct?

Name: Anonymous 2011-09-16 3:23

>>74 cretin

Name: Anonymous 2011-09-16 3:37

>>74
You can't.  Now go to ##C so you can get your dick ripped off.

Furthermore, please stop decreasing the average ``quality of post'' for ∀Post("n3n7i").

Name: n3n7i 2011-09-16 3:43

i am a nigger please give me welfare

Name: n3n7i 2011-09-16 6:49

...Might not be such a problem hopefully, can just about use int's for everything?

//Side-by-side struct width extensions..?

Name: n3n7i 2011-09-17 6:31

io kliovme tzghevm diockls

klioiokl atz vmy sruperuioioru tzypiobngh sklioklkltzs

pruioghghkles ios ghioklaruioiorus

ghioiod kliorud io'vm ghavmiobngh a seiotzrurue gherue

ctzghruklghru fjtzghaghbn

Name: Anonymous 2011-09-17 6:46

>>1
C should have all this in stdlib, but it sucks so it doesn't. Let's see...

- I hope the Unicode strings library is not zero-terminated.
- A similar non-zero-terminated strings library for binrary-safe octet streams without any specific character encoding should be useful too, unless your Unicode strings library can handle invalid data and be used for this.
- Cons lists (as in Lisp)
- Variable-length, dynamically allocated vectors (as in Python)
- Dictionaries (as they work Python)
- Utilities to deal with and convert these as necessary
- Optional garbage collector? Don't implement a new one, see if you can include any other project.
- I'd leave OS abstractions last as you can use POSIX functionality, but if you get to it, overflows and shit C is missing, common terminal handling, low-level I/O, common ioctls, files and directories, sockets, threads and common process launching, handling and signaling are my top preferences.

>>5
He'll end making C useful?

>>6
I don't think C is fit for that (or anything lol), but if you think it is, esp. for dealing/iterating through lists and dictionaries, why not?

>>7-34
tl;dr

>>35
Die faggot

>>37
idiot idiot idiot idiot

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