Update of /cvsroot/pure-data/externals/mrpeach/osc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8326
Modified Files: packOSC.c Log Message: Removed hardcoded limit on number of arguments.
Index: packOSC.c =================================================================== RCS file: /cvsroot/pure-data/externals/mrpeach/osc/packOSC.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** packOSC.c 15 Feb 2007 23:07:18 -0000 1.2 --- packOSC.c 28 May 2007 00:45:58 -0000 1.3 *************** *** 31,35 **** */
- #define MAX_ARGS 2000 #define SC_BUFFER_SIZE 64000
--- 31,34 ---- *************** *** 323,350 **** static void packOSC_sendtyped(t_packOSC *x, t_symbol *s, int argc, t_atom *argv) { ! char messageName[MAXPDSTRING]; ! char typeStr[MAX_ARGS]; ! typedArg args[MAX_ARGS]; ! int i, j, k, nTags, nArgs; ! char c; ! ! messageName[0] = '\0'; // empty
! if(argc>MAX_ARGS) { ! post ("packOSC: too many arguments! (max: %d)", MAX_ARGS); return; }
atom_string(&argv[0], messageName, MAXPDSTRING); /* the OSC address string */ if (x->x_typetags & 2) ! { /* first arg is typestring */ typeStr[0] = ','; ! atom_string(&argv[1], &typeStr[1], MAXPDSTRING); nArgs = argc-2; ! for (i = nTags = 0; i < MAX_ARGS; ++i) { ! if (typeStr[i+1] == 0) break; ! if (!(typeStr[i+1] == 'T' || typeStr[i+1] == 'F' || typeStr[i+1] == 'N' || typeStr[i+1] == 'I')) ++nTags; /* these tags have data */ } --- 322,366 ---- static void packOSC_sendtyped(t_packOSC *x, t_symbol *s, int argc, t_atom *argv) { ! char messageName[MAXPDSTRING]; ! unsigned int nTypeTags = 0, typeStrTotalSize; ! unsigned int argsSize = sizeof(typedArg)*argc; ! char* typeStr = NULL; /* might not be used */ ! typedArg* args = (typedArg*)getbytes(argsSize); ! int i, nTags, nArgs; ! unsigned int m, j, k; ! char c;
! if (args == NULL) { ! post("packOSC: unable to allocate %lu bytes for args", argsSize); return; } + messageName[0] = '\0'; // empty
atom_string(&argv[0], messageName, MAXPDSTRING); /* the OSC address string */ if (x->x_typetags & 2) ! { /* second arg is typestring */ ! /* we need to find out how long the type string is before we copy it*/ ! nTypeTags = strlen(atom_getsymbol(&argv[1])->s_name); ! typeStrTotalSize = nTypeTags + 2; ! typeStr = (char*)getzbytes(typeStrTotalSize); ! if (typeStr == NULL) ! { ! post("packOSC: unable to allocate %lu bytes for typeStr", nTypeTags); ! return; ! } typeStr[0] = ','; ! atom_string(&argv[1], &typeStr[1], typeStrTotalSize); ! #ifdef DEBUG ! post("typeStr: %s, nTypeTags %lu", typeStr, nTypeTags); ! #endif nArgs = argc-2; ! for (m = nTags = 0; m < nTypeTags; ++m) { ! #ifdef DEBUG ! post("typeStr[%d] %c", m+1, typeStr[m+1]); ! #endif ! if ((c = typeStr[m+1]) == 0) break; ! if (!(c == 'T' || c == 'F' || c == 'N' || c == 'I')) ++nTags; /* these tags have data */ } *************** *** 352,358 **** { post("packOSC: Tags count %d doesn't match argument count %d", nTags, nArgs); ! return; } ! for (j = k = 0; j < i; ++j) /* i is the number of tags */ { c = typeStr[j+1]; --- 368,374 ---- { post("packOSC: Tags count %d doesn't match argument count %d", nTags, nArgs); ! goto cleanup; } ! for (j = k = 0; j < m; ++j) /* m is the number of tags */ { c = typeStr[j+1]; *************** *** 366,370 **** { post("packOSC: usage error, write-msg failed."); ! return; } } --- 382,386 ---- { post("packOSC: usage error, write-msg failed."); ! goto cleanup; } } *************** *** 396,400 **** { post("packOSC: usage error, write-msg failed."); ! return; } } --- 412,416 ---- { post("packOSC: usage error, write-msg failed."); ! goto cleanup; } } *************** *** 405,408 **** --- 421,428 ---- OSC_initBuffer(x->x_oscbuf, SC_BUFFER_SIZE, bufferForOSCbuf); } + + cleanup: + if (typeStr != NULL) freebytes(typeStr, typeStrTotalSize); + if (args != NULL) freebytes(args, argsSize); }
*************** *** 646,650 **** { /* First figure out the type tags */ ! char typeTags[MAX_ARGS+2];
typeTags[0] = ','; --- 666,670 ---- { /* First figure out the type tags */ ! char *typeTags=(char*)getbytes(sizeof(char)*(numArgs+2));
typeTags[0] = ','; *************** *** 673,676 **** --- 693,697 ---- post("packOSC: Problem writing address."); } + freebytes(typeTags, sizeof(char)*(numArgs+2)); } for (j = 0; j < numArgs; j++)