Back to index

nordugrid-arc-nox  1.1.0~rc6
Typedefs | Functions
listfunc.h File Reference
#include <stdlib.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* freefn )(void *)
 Borrow the code about list operation from VOMS, specially for list of Attribute Certificate.

Functions

char ** listjoin (char **base, char **addon, int size)
char ** listadd (char **vect, char *data, int size)
void listfree (char **vect, freefn f)

Typedef Documentation

typedef void(* freefn)(void *)

Borrow the code about list operation from VOMS, specially for list of Attribute Certificate.

Because the AC** operator is required for i2d_AC() and d2i_AC() method, and implicitly required by OpenSSL code, some other solution like std::list<AC*> is not suitable here.The listfunc.h and listfunc.h are introduced from code written by VOMS project, *so here the original license follows.

Definition at line 19 of file listfunc.h.


Function Documentation

char** listadd ( char **  vect,
char *  data,
int  size 
)

Definition at line 36 of file listfunc.c.

                                                  {
  int i = 0;
  char **newvect;

  if (!data || (size <= 0))
    return NULL;

  if (vect)
    while (vect[i++]) ;
  else
    i=1;

  if ((newvect = (char **)malloc((i+1)*size))) {
    if (vect) {
      memcpy(newvect, vect, (size*(i-1)));
      newvect[i-1] = data;
      newvect[i] = NULL;
      free(vect);
    }
    else {
      newvect[0] = data;
      newvect[1] = NULL;
    }
    return newvect;
  }
  return NULL;
}

Here is the caller graph for this function:

void listfree ( char **  vect,
freefn  f 
)

Definition at line 64 of file listfunc.c.

                                              {
  char **tmp = vect;
  if (tmp) {
    int i = 0;
    while (tmp[i])
      f(tmp[i++]);
    free(vect);
  }
}

Here is the caller graph for this function:

char** listjoin ( char **  base,
char **  addon,
int  size 
)

Definition at line 6 of file listfunc.c.

                                                     {
  char **store = addon, 
    **storebase = base,
    **newvect = NULL;
  int num = 0, num2=0;
  int i;

  if (!addon || !(*addon))
    return base;

  while (*store++)
    num++;

  if (storebase)
    while (*storebase++)
      num2++;

  if ((newvect = (char **)malloc((num+num2+1)*size))) {
    if (newvect) {
      memcpy(newvect, base, (size*(num2)));
      for (i=num2; i <num+num2; i++)
        newvect[i] = addon[i-num2];
      newvect[i] = NULL;
      free(base);
      return newvect;
    }
   }
  return NULL;
}