summaryrefslogtreecommitdiff
path: root/src/libstddjb/stralloc_shrink.c
blob: 0dceca203768ebb48bf2ca587214ad8e969a3cf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* ISC license. */

#include <skalibs/alloc.h>
#include <skalibs/stralloc.h>

int stralloc_shrink (stralloc *sa)
{
  if (sa->a > sa->len)
  {
    if (!alloc_re(&sa->s, sa->a, sa->len)) return 0 ;
    sa->a = sa->len ;
  }
  return 1 ;
}