Back to index

tetex-bin  3.0
Defines | Functions
fn.c File Reference
#include <kpathsea/config.h>
#include <kpathsea/fn.h>

Go to the source code of this file.

Defines

#define CHUNK_SIZE   75

Functions

fn_type fn_init P1H (void)
fn_type fn_copy0 P2C (const_string, s, unsigned, len)
void fn_free P1C (fn_type *, f)
static void grow P2C (fn_type *, f, unsigned, len)
void fn_1grow P2C (fn_type *, f, char, c)
void fn_grow P3C (fn_type *, f, const_string, source, unsigned, len)
void fn_str_grow P2C (fn_type *, f, const_string, s)
void fn_shrink_to P2C (fn_type *, f, unsigned, loc)

Define Documentation

#define CHUNK_SIZE   75

Definition at line 26 of file fn.c.


Function Documentation

void fn_free P1C ( fn_type ,
f   
)

Definition at line 60 of file fn.c.

{
  assert (FN_STRING (*f) != NULL);
  free (FN_STRING (*f));
  FN_STRING (*f) = NULL;
  FN_ALLOCATED (*f) = 0;
  FN_LENGTH (*f) = 0;
}

Here is the call graph for this function:

fn_type fn_init P1H ( void  ) [read]

Definition at line 30 of file fn.c.

{
  fn_type ret;
  
  FN_ALLOCATED (ret) = FN_LENGTH (ret) = 0;
  FN_STRING (ret) = NULL;
  
  return ret;
}
fn_type fn_copy0 P2C ( const_string  ,
s  ,
unsigned  ,
len   
)

Definition at line 42 of file fn.c.

{
  fn_type ret;
  
  FN_ALLOCATED (ret) = CHUNK_SIZE > len ? CHUNK_SIZE : len + 1;
  FN_STRING (ret) = (string)xmalloc (FN_ALLOCATED (ret));
  
  strncpy (FN_STRING (ret), s, len);
  FN_STRING (ret)[len] = 0;
  FN_LENGTH (ret) = len + 1;
  
  return ret;
}

Here is the call graph for this function:

static void grow P2C ( fn_type ,
f  ,
unsigned  ,
len   
) [static]

Definition at line 75 of file fn.c.

{
  while (FN_LENGTH (*f) + len > FN_ALLOCATED (*f))
    {
      FN_ALLOCATED (*f) += CHUNK_SIZE;
      XRETALLOC (FN_STRING (*f), FN_ALLOCATED (*f), char);
    }
}
void fn_1grow P2C ( fn_type ,
f  ,
char  ,
c   
)

Definition at line 86 of file fn.c.

{
  grow (f, 1);
  FN_STRING (*f)[FN_LENGTH (*f)] = c;
  FN_LENGTH (*f)++;
}
void fn_str_grow P2C ( fn_type ,
f  ,
const_string  ,
s   
)

Definition at line 104 of file fn.c.

{
  unsigned more_len = strlen (s);
  grow (f, more_len);
  strcat (FN_STRING (*f), s);
  FN_LENGTH (*f) += more_len;
}

Here is the call graph for this function:

void fn_shrink_to P2C ( fn_type ,
f  ,
unsigned  ,
loc   
)

Definition at line 114 of file fn.c.

{
  assert (FN_LENGTH (*f) > loc);
  FN_STRING (*f)[loc] = 0;
  FN_LENGTH (*f) = loc + 1;
}
void fn_grow P3C ( fn_type ,
f  ,
const_string  ,
source  ,
unsigned  ,
len   
)

Definition at line 95 of file fn.c.

{
  grow (f, len);
  strncpy (FN_STRING (*f) + FN_LENGTH (*f), source, len);
  FN_LENGTH (*f) += len;
}

Here is the call graph for this function: