[BACK]Return to handler.c CVS log [TXT][DIR] Up to [pgFoundry] / libpqtypes / libpqtypes / src

Diff for /libpqtypes/libpqtypes/src/handler.c between version 1.6 and 1.7

version 1.6, 2008/09/05 16:42:50 version 1.7, 2008/09/11 15:55:51
Line 211  pqt_duphandlers(PGtypeHandler *handlers,
Line 211  pqt_duphandlers(PGtypeHandler *handlers,
         if(!h)          if(!h)
                 return NULL;                  return NULL;
   
         memcpy(h, handlers, hcnt * sizeof(PGtypeHandler));  
   
         /* deep copy schema, typname and the PGrecordAttDesc array */          /* deep copy schema, typname and the PGrecordAttDesc array */
         for(i=0; i < hcnt; i++)          for(i=0; i < hcnt; i++)
         {          {
                 if(handlers[i].typschema)                  memcpy(&h[i], &handlers[i], sizeof(PGtypeHandler));
                         h[i].typschema = strdup(handlers[i].typschema);  
   
                 if(handlers[i].typname)                  /* requires a deep copy */
                         h[i].typname = strdup(handlers[i].typname);                  h[i].nattrs = 0;
                   h[i].typschema = h[i].typname = h[i].attDescs = h[i].orig_typname = NULL;
   
                 if(handlers[i].orig_typname)                  if(handlers[i].typschema && !(h[i].typschema = strdup(handlers[i].typschema)))
                         h[i].orig_typname = strdup(handlers[i].orig_typname);                  {
                           pqt_freehandlers(h, i+1);
                           return NULL;
                   }
   
                   if(handlers[i].typname && !(h[i].typname = strdup(handlers[i].typname)))
                   {
                           pqt_freehandlers(h, i+1);
                           return NULL;
                   }
   
                   if(handlers[i].orig_typname && !(h[i].orig_typname = strdup(handlers[i].orig_typname)))
                   {
                           pqt_freehandlers(h, i+1);
                           return NULL;
                   }
   
                 if(handlers[i].nattrs == 0)                  if(handlers[i].nattrs == 0)
                         continue;                          continue;
   
                 h[i].attDescs = (PGrecordAttDesc *)malloc(                  h[i].attDescs = (PGrecordAttDesc *)malloc(
                         handlers[i].nattrs * sizeof(PGrecordAttDesc));                          handlers[i].nattrs * sizeof(PGrecordAttDesc));
   
                 if(!h[i].attDescs)                  if(!h[i].attDescs)
                 {                  {
                         pqt_freehandlers(h, i+1);                          pqt_freehandlers(h, i+1);
                         return NULL;                          return NULL;
                 }                  }
   
                 memcpy(h[i].attDescs, handlers[i].attDescs,                  for(n=0; n < handlers[i].nattrs; n++, h[i].nattrs++)
                         handlers[i].nattrs * sizeof(PGrecordAttDesc));                  {
                           char *name = strdup(handlers[i].attDescs[n].attname);
   
                 for(n=0; n < handlers[i].nattrs; n++)                          if(!name)
                         h[i].attDescs[n].attname = strdup(                          {
                                 handlers[i].attDescs[n].attname);                                  pqt_freehandlers(h, i+1);
                                   return NULL;
                           }
   
                           h[i].attDescs[n].attName   = name;
                           h[i].attDescs[n].attoid    = handlers[i].attDescs[n].attoid;
                           h[i].attDescs[n].attlen    = handlers[i].attDescs[n].attlen;
                           h[i].attDescs[n].atttypmod = handlers[i].attDescs[n].atttypmod;
                   }
         }          }
   
         return h;          return h;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

PgFoundry-cvsweb <pgfoundry-cvsweb@pgFoundry.org>