summaryrefslogtreecommitdiff
path: root/src/libstddjb/stralloc_shrink.c
blob: a372084b2601039c24729256545d0e362cf99ea0 (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((void **)&sa->s, sa->a, sa->len)) return 0 ;
    sa->a = sa->len ;
  }
  return 1 ;
}