/[svn]/liblscp/trunk/src/common.c
ViewVC logotype

Diff of /liblscp/trunk/src/common.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 378 by capela, Sun Feb 13 17:20:46 2005 UTC revision 415 by capela, Tue Mar 1 21:55:34 2005 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This library is free software; you can redistribute it and/or     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public     modify it under the terms of the GNU Lesser General Public
# Line 329  char **lscp_szsplit_create ( const char Line 329  char **lscp_szsplit_create ( const char
329              --pch;              --pch;
330          *pch = (char) 0;          *pch = (char) 0;
331          // Make it official.          // Make it official.
332          ppszSplit[i++] = lscp_unquote(&pszHead, 0);          ppszSplit[i] = lscp_unquote(&pszHead, 0);
333          // Do we need to grow?          // Do we need to grow?
334          if (i >= iSize) {          if (++i >= iSize - 1) {
335              // Yes, but only grow in chunks.              // Yes, but only grow in chunks.
336              iSize += LSCP_SPLIT_CHUNK1;              iSize += LSCP_SPLIT_CHUNK1;
337              // Allocate and copy to new split array.              // Allocate and copy to new split array.
# Line 396  int *lscp_isplit_create ( const char *ps Line 396  int *lscp_isplit_create ( const char *ps
396      pchHead = lscp_ltrim((char *) pszCsv);      pchHead = lscp_ltrim((char *) pszCsv);
397      if (*pchHead == (char) 0)      if (*pchHead == (char) 0)
398          return NULL;          return NULL;
399        
400      // Initial size is one chunk away.      // Initial size is one chunk away.
401      iSize = LSCP_SPLIT_CHUNK1;      iSize = LSCP_SPLIT_CHUNK1;
402      // Allocate and split...      // Allocate and split...
# Line 417  int *lscp_isplit_create ( const char *ps Line 417  int *lscp_isplit_create ( const char *ps
417          // Pre-advance to next item.          // Pre-advance to next item.
418          pchHead = pch + cchSeps;          pchHead = pch + cchSeps;
419          // Make it official.          // Make it official.
420          piSplit[i++] = atoi(pchHead);          piSplit[i] = atoi(pchHead);
421          // Do we need to grow?          // Do we need to grow?
422          if (i >= iSize) {          if (++i >= iSize - 1) {
423              // Yes, but only grow in chunks.              // Yes, but only grow in chunks.
424              iSize += LSCP_SPLIT_CHUNK1;              iSize += LSCP_SPLIT_CHUNK1;
425              // Allocate and copy to new split array.              // Allocate and copy to new split array.
# Line 500  lscp_param_t *lscp_psplit_create ( const Line 500  lscp_param_t *lscp_psplit_create ( const
500              pszHead = pch + cchSeps2;              pszHead = pch + cchSeps2;
501              *pch = (char) 0;              *pch = (char) 0;
502          }          }
503          if (++i >= iSize) {          if (++i >= iSize - 1) {
504              iSize += LSCP_SPLIT_CHUNK1;              iSize += LSCP_SPLIT_CHUNK1;
505              ppNewSplit = (lscp_param_t *) malloc(iSize * sizeof(lscp_param_t));              ppNewSplit = (lscp_param_t *) malloc(iSize * sizeof(lscp_param_t));
506              if (ppNewSplit) {              if (ppNewSplit) {
# Line 581  void lscp_plist_free ( lscp_param_t **pp Line 581  void lscp_plist_free ( lscp_param_t **pp
581  {  {
582      lscp_param_t *pParams;      lscp_param_t *pParams;
583      int i;      int i;
584        
585      if (ppList) {      if (ppList) {
586          if (*ppList) {          if (*ppList) {
587              pParams = *ppList;              pParams = *ppList;
# Line 603  void lscp_plist_append ( lscp_param_t ** Line 603  void lscp_plist_append ( lscp_param_t **
603      lscp_param_t *pNewParams;      lscp_param_t *pNewParams;
604      int iSize, iNewSize;      int iSize, iNewSize;
605      int i = 0;      int i = 0;
606        
607      if (ppList && *ppList) {      if (ppList && *ppList) {
608          pParams = *ppList;          pParams = *ppList;
609          while (pParams[i].key) {          while (pParams[i].key) {
# Line 618  void lscp_plist_append ( lscp_param_t ** Line 618  void lscp_plist_append ( lscp_param_t **
618          iSize = LSCP_SPLIT_SIZE(i);          iSize = LSCP_SPLIT_SIZE(i);
619          pParams[i].key   = strdup(pszKey);          pParams[i].key   = strdup(pszKey);
620          pParams[i].value = strdup(pszValue);          pParams[i].value = strdup(pszValue);
621          if (++i >= iSize) {          if (++i >= iSize - 1) {
622              iNewSize   = iSize + LSCP_SPLIT_CHUNK1;              iNewSize   = iSize + LSCP_SPLIT_CHUNK1;
623              pNewParams = (lscp_param_t *) malloc(iNewSize * sizeof(lscp_param_t));              pNewParams = (lscp_param_t *) malloc(iNewSize * sizeof(lscp_param_t));
624              for (i = 0; i < iSize; i++) {              for (i = 0; i < iSize; i++) {
625                  pParams[i].key   = pParams[i].key;                  pNewParams[i].key   = pParams[i].key;
626                  pParams[i].value = pParams[i].value;                  pNewParams[i].value = pParams[i].value;
627              }              }
628              for ( ; i < iNewSize; i++) {              for ( ; i < iNewSize; i++) {
629                  pNewParams[i].key   = NULL;                  pNewParams[i].key   = NULL;

Legend:
Removed from v.378  
changed lines
  Added in v.415

  ViewVC Help
Powered by ViewVC