static void po_free_dir_list(Popot plist) /***************************************************************************** * void FreeDirList(char ***list); ****************************************************************************/ { Popot *list; if ((list = plist.pt) == NULL) { builtin_err = Err_null_ref; return; } if (list->pt != NULL) { po_free(*list); list->pt = list->min = list->max = NULL; } }
Errcode po_poly_to_arrays(Poly *p, Popot *px, Popot *py) /***************************************************************************** * Convert a polygon to two poco int arrays ****************************************************************************/ { Popot x,y; long acount; acount = p->pt_count*sizeof(int); x = poco_lmalloc(acount); if (x.pt == NULL) return(Err_no_memory); y = poco_lmalloc(acount); if (y.pt == NULL) { po_free(x); return(Err_no_memory); } poly_to_arrays(p, x.pt, y.pt); *px = x; *py = y; return(Success); }
void simple_free_test() { /* do some mallocs, free it all, do the mallocs again (sbrk should not move) */ int i, j, len; char * bufs[100]; void * cur_brk; for (i = 0; i < 100; i++) { len = 100 + i; bufs[i] = po_malloc(len); for (j = 0; j < len - 1; j++) { bufs[i][j] = '0' + (i % 10); } bufs[i][len - 1] = '\0'; } for (i = 0; i < 100; i++) { printf("%02d [0x%08lX]: %s\n", i, (unsigned long)bufs[i], (char *)bufs[i]); } cur_brk = sbrk(0); for (i = 0; i < 100; i++) { po_free(bufs[i]); } for (i = 0; i < 100; i++) { len = 100 + i; bufs[i] = po_malloc(len); for (j = 0; j < len - 1; j++) { bufs[i][j] = '0' + (i % 10); } bufs[i][len - 1] = '\0'; } printf("== sbrk(0): bfr 0x%08lX, after 0x%08lX ==\n", (unsigned long)cur_brk, (unsigned long)sbrk(0)); for (i = 0; i < 100; i++) { printf("%02d [0x%08lX]: %s\n", i, (unsigned long)bufs[i], (char *)bufs[i]); } }
int main (int argc, char **argv) { int c; /* -- */ gboolean istats = FALSE; gboolean copy_msgid = FALSE; gboolean preserve_wrapping = FALSE; PoFilters ifilters = 0; po_write_modes write_mode = 0; while ((c = getopt (argc, argv, "f:n:scph")) != EOF) { switch (c) { case 'h' : fprintf (stderr, _( "Usage: %s FILENAME1 [FILENAME2] [FILTERS] [-s] [-c] [-p] [-h]\n" "\n" ), argv[0]); exit (EXIT_SUCCESS); break; case 'n' : if (strcmp (optarg, "ctxt") == 0) { write_mode |= NO_CTX; } else if (strcmp (optarg, "id") == 0) { write_mode |= NO_ID; } else if (strcmp (optarg, "str") == 0) { write_mode |= NO_STR; } else if (strcmp (optarg, "cmt") == 0) { write_mode |= NO_STD_COMMENT | NO_POS_COMMENT | NO_SPEC_COMMENT | NO_RES_COMMENT; } else if (strcmp (optarg, "ucmt") == 0) { write_mode |= NO_STD_COMMENT; } else if (strcmp (optarg, "pcmt") == 0) { write_mode |= NO_POS_COMMENT; } else if (strcmp (optarg, "scmt") == 0) { write_mode |= NO_SPEC_COMMENT; } else if (strcmp (optarg, "dcmt") == 0) { write_mode |= NO_RES_COMMENT; } else if (strcmp (optarg, "tr") == 0) { write_mode |= NO_TRANSLATION; } else if (strcmp (optarg, "linf") == 0) { write_mode |= NO_LINF; } else { po_error (_("Unknown parameter for -n option!")); } break; case 's' : istats = TRUE; break; case 'c': copy_msgid = TRUE; break; case 'p': preserve_wrapping = TRUE; break; case 'f' : if (strcmp (optarg, "f") == 0) { ifilters |= FUZZY_FILTER; } else if (strcmp (optarg, "nf") == 0) { ifilters |= NOT_FUZZY_FILTER; } else if (strcmp (optarg, "t") == 0) { ifilters |= TRANSLATED_FILTER; } else if (strcmp (optarg, "nt") == 0) { ifilters |= NOT_TRANSLATED_FILTER; } else if (strcmp (optarg, "nth") == 0) { ifilters |= NOT_TRANSLATED_H_FILTER; } else if (strcmp (optarg, "o") == 0) { ifilters |= OBSOLETE_FILTER; } else if (strcmp (optarg, "no") == 0) { ifilters |= NOT_OBSOLETE_FILTER; } else { po_error (_("Unknown filter \"%s\"!"), optarg); } break; case ':' : po_error (_("Invalid parameter!")); break; case '?' : po_error (_("Invalid option!")); break; default : g_assert_not_reached (); } } if (optind >= argc) { po_error (_("Input file not specified!")); } if (argc - optind == 1) { PoFile *pof; char *ifn = argv[optind]; pof = po_read (ifn); po_apply_filters (pof, ifilters); if (istats) { potool_printf (_("%d\n"), g_slist_length (pof->entries)); } else { if (copy_msgid) { po_copy_msgid (pof); } po_write (pof, write_mode, preserve_wrapping); } po_free (pof); } else { PoFile *bpof, *pof; PoEntry_set *bpo_set; char *bfn = argv[optind], *fn = argv[optind + 1]; bpof = po_read (bfn); bpo_set = po_set_create (bpof->entries); pof = po_read (fn); po_apply_filters (pof, ifilters); if (copy_msgid) { po_copy_msgid (pof); } bpo_set = po_set_update (bpo_set, pof->entries); po_write (bpof, write_mode, preserve_wrapping); g_hash_table_destroy (bpo_set); po_free (bpof); po_free (pof); } if (fflush(stdout) != 0) po_error(_("fflush(stdout) failed: %s"), strerror(errno)); return 0; }