MCPcopy Create free account
hub / github.com/creatale/node-dv / NewIntClass

Function NewIntClass

deps/tesseract/classify/intproto.cpp:664–700  ·  view source on GitHub ↗

* This routine creates a new integer class data structure * and returns it. Sufficient space is allocated * to handle the specified number of protos and configs. * @param MaxNumProtos number of protos to allocate space for * @param MaxNumConfigs number of configs to allocate space for * @return New class created. * @note Globals: none * @note Exceptions: none * @note History: Fri Feb 8

Source from the content-addressed store, hash-verified

662 * @note History: Fri Feb 8 10:51:23 1991, DSJ, Created.
663 */
664INT_CLASS NewIntClass(int MaxNumProtos, int MaxNumConfigs) {
665 INT_CLASS Class;
666 PROTO_SET ProtoSet;
667 int i;
668
669 assert(MaxNumConfigs <= MAX_NUM_CONFIGS);
670
671 Class = (INT_CLASS) Emalloc(sizeof(INT_CLASS_STRUCT));
672 Class->NumProtoSets = ((MaxNumProtos + PROTOS_PER_PROTO_SET - 1) /
673 PROTOS_PER_PROTO_SET);
674
675 assert(Class->NumProtoSets <= MAX_NUM_PROTO_SETS);
676
677 Class->NumProtos = 0;
678 Class->NumConfigs = 0;
679
680 for (i = 0; i < Class->NumProtoSets; i++) {
681 /* allocate space for a proto set, install in class, and initialize */
682 ProtoSet = (PROTO_SET) Emalloc(sizeof(PROTO_SET_STRUCT));
683 memset(ProtoSet, 0, sizeof(*ProtoSet));
684 Class->ProtoSets[i] = ProtoSet;
685
686 /* allocate space for the proto lengths and install in class */
687 }
688 if (MaxNumIntProtosIn (Class) > 0) {
689 Class->ProtoLengths =
690 (uinT8 *)Emalloc(MaxNumIntProtosIn (Class) * sizeof (uinT8));
691 memset(Class->ProtoLengths, 0,
692 MaxNumIntProtosIn(Class) * sizeof(*Class->ProtoLengths));
693 } else {
694 Class->ProtoLengths = NULL;
695 }
696 memset(Class->ConfigLengths, 0, sizeof(Class->ConfigLengths));
697
698 return (Class);
699
700} /* NewIntClass */
701
702
703void free_int_class(INT_CLASS int_class) {

Callers 3

CreateIntTemplatesMethod · 0.85
ReadIntTemplatesMethod · 0.85
AddAdaptedClassFunction · 0.85

Calls 1

EmallocFunction · 0.85

Tested by

no test coverage detected