Logo Search packages:      
Sourcecode: bglibs version File versions

int str_truncate ( str s,
unsigned  len 

Truncate a string.

If len is larger than the current size, the string is reallocated. If len is less than the existing length (not size), the length of the string is reduced to len. A NUL marker is placed at len.

Definition at line 27 of file truncate.c.

References len, s, and str_realloc.

Referenced by str_lcut(), str_rcut(), and str_sort().

  if (!str_realloc(s, len)) return 0;
  if (len < s->len)
    s->len = len;
  s->s[len] = 0;
  return 1;

Generated by  Doxygen 1.6.0   Back to index