X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common%2Fmem.h;h=f7b9d8021f1fe595b4d1cdffeeee6bc0fb51b965;hb=3ecf64721aea62f951481e8d39386347ced81db6;hp=44630efc2ca6c187373e052e1754b355424e5cc7;hpb=8977d252fc44ae953df4bde4a2f1c5895beea4e0;p=apps%2Fpfixtools.git diff --git a/common/mem.h b/common/mem.h index 44630ef..f7b9d80 100644 --- a/common/mem.h +++ b/common/mem.h @@ -53,6 +53,14 @@ #define p_dupstr(p, len) xmemdupstr((p), (len)) #define p_realloc(pp, count) xrealloc((void*)(pp), sizeof(**(pp)) * (count)) +# define p_shrink(pp, goalnb, allocnb) \ + do { \ + if (*(allocnb) > goalnb) { \ + p_realloc(pp, goalnb); \ + *(allocnb) = goalnb; \ + } \ + } while(0) + # define p_alloc_nr(x) (((x) + 16) * 3 / 2) # define p_allocgrow(pp, goalnb, allocnb) \ do { \