MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / ply_close

Function ply_close

src/IO/rply.c:668–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

666}
667
668int ply_close(p_ply ply) {
669 long i;
670 assert(ply && ply->fp);
671 assert(ply->element || ply->nelements == 0);
672 assert(!ply->element || ply->nelements > 0);
673 /* write last chunk to file */
674 if (ply->io_mode == PLY_WRITE &&
675 fwrite(ply->buffer, 1, ply->buffer_last, ply->fp) < ply->buffer_last) {
676 ply_ferror(ply, "Error closing up");
677 return 0;
678 }
679 fclose(ply->fp);
680 /* free all memory used by handle */
681 if (ply->element) {
682 for (i = 0; i < ply->nelements; i++) {
683 p_ply_element element = &ply->element[i];
684 if (element->property) free(element->property);
685 }
686 free(ply->element);
687 }
688 if (ply->obj_info) free(ply->obj_info);
689 if (ply->comment) free(ply->comment);
690 free(ply);
691 return 1;
692}
693
694/* ----------------------------------------------------------------------
695 * Query support functions

Callers 2

write_meshMethod · 0.85
parse_plyFunction · 0.85

Calls 1

ply_ferrorFunction · 0.85

Tested by

no test coverage detected