Skip to content

igorsobreira/iclib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

iclib

Library with useful C data structures

vector

A vector is type agnostic structure similar to a list that grows as needed.

Running tests

Install check, unit tests framework. Now you can run the lib tests:

$ cd vector
$ make

Usage example

This example creates a vector of strings with initial 10 positions allocated:

#include <stdio.h>
#include <string.h>
#include "vector.h"

void free_string(void *string) {
  free(*(char **)string);
}

int main(void) {
  vector *v = vector_new(sizeof(char *), free_string, 10);
  
  char *name = strdup("Igor");
  vector_append(v, &name);
  
  printf("%s \n", *(char **)vector_get(v, 0));

  vector_free(v);
  return EXIT_SUCCESS;
}

About

Library with useful C data structures

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages