Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20325
Modified Files: Tag: desiredata d_soundfile.c kernel.c s_loader.c Log Message: removed some MAXPDSTRING by using canvas_open2
Index: s_loader.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_loader.c,v retrieving revision 1.4.4.5.2.10.2.6 retrieving revision 1.4.4.5.2.10.2.7 diff -C2 -d -r1.4.4.5.2.10.2.6 -r1.4.4.5.2.10.2.7 *** s_loader.c 18 Jul 2007 20:52:38 -0000 1.4.4.5.2.10.2.6 --- s_loader.c 19 Jul 2007 01:30:16 -0000 1.4.4.5.2.10.2.7 *************** *** 104,114 ****
static int sys_do_load_lib(t_canvas *canvas, char *objectname) { ! char filename[MAXPDSTRING], dirbuf[MAXPDSTRING], *classname, *nameptr; ! void *dlobj; t_xxx makeout = NULL; int fd; - #ifdef MSW - HINSTANCE ntdll; - #endif if ((classname = strrchr(objectname, '/'))) classname++; else classname = objectname; --- 104,110 ----
static int sys_do_load_lib(t_canvas *canvas, char *objectname) { ! char filename[MAXPDSTRING], *dirbuf, *classname, *nameptr; t_xxx makeout = NULL; int fd; if ((classname = strrchr(objectname, '/'))) classname++; else classname = objectname; *************** *** 119,125 **** char *symname = make_setup_name(classname); /* try looking in the path for (objectname).(sys_dllextent) ... */ ! if ((fd = canvas_open(canvas, objectname, sys_dllextent , dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; /* same, with the more generic sys_dllextent2 */ ! if ((fd = canvas_open(canvas, objectname, sys_dllextent2, dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; /* next try (objectname)/(classname).(sys_dllextent) ... */ strncpy(filename, objectname, MAXPDSTRING); --- 115,121 ---- char *symname = make_setup_name(classname); /* try looking in the path for (objectname).(sys_dllextent) ... */ ! if ((fd = canvas_open2(canvas, objectname, sys_dllextent , &dirbuf, &nameptr, 1)) >= 0) goto gotone; /* same, with the more generic sys_dllextent2 */ ! if ((fd = canvas_open2(canvas, objectname, sys_dllextent2, &dirbuf, &nameptr, 1)) >= 0) goto gotone; /* next try (objectname)/(classname).(sys_dllextent) ... */ strncpy(filename, objectname, MAXPDSTRING); *************** *** 128,133 **** strncat(filename, classname, MAXPDSTRING-strlen(filename)); filename[MAXPDSTRING-1] = 0; ! if ((fd = canvas_open(canvas, filename, sys_dllextent , dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; ! if ((fd = canvas_open(canvas, filename, sys_dllextent2, dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; return 0; gotone: --- 124,129 ---- strncat(filename, classname, MAXPDSTRING-strlen(filename)); filename[MAXPDSTRING-1] = 0; ! if ((fd = canvas_open2(canvas, filename, sys_dllextent , &dirbuf, &nameptr, 1)) >= 0) goto gotone; ! if ((fd = canvas_open2(canvas, filename, sys_dllextent2, &dirbuf, &nameptr, 1)) >= 0) goto gotone; return 0; gotone: *************** *** 141,149 **** filename[MAXPDSTRING-1] = 0; #ifdef DL_OPEN ! dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); if (!dlobj) { post("%s: %s", filename, dlerror()); class_set_extern_dir(&s_); ! free(symname); return 0; } --- 137,145 ---- filename[MAXPDSTRING-1] = 0; #ifdef DL_OPEN ! void *dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); if (!dlobj) { post("%s: %s", filename, dlerror()); class_set_extern_dir(&s_); ! free(symname); free(dirbuf); return 0; } *************** *** 152,160 **** #ifdef MSW sys_bashfilename(filename, filename); ! ntdll = LoadLibrary(filename); if (!ntdll) { post("%s: couldn't load", filename); class_set_extern_dir(&s_); ! free(symname); return 0; } --- 148,156 ---- #ifdef MSW sys_bashfilename(filename, filename); ! HINSTANCE ntdll = LoadLibrary(filename); if (!ntdll) { post("%s: couldn't load", filename); class_set_extern_dir(&s_); ! free(symname); free(dirbuf); return 0; } *************** *** 164,168 **** post("%s: can't find symbol '%s' in library", filename, symname); class_set_extern_dir(&s_); ! free(symname); return 0; } --- 160,164 ---- post("%s: can't find symbol '%s' in library", filename, symname); class_set_extern_dir(&s_); ! free(symname); free(dirbuf); return 0; }
Index: kernel.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v retrieving revision 1.1.2.63 retrieving revision 1.1.2.64 diff -C2 -d -r1.1.2.63 -r1.1.2.64 *** kernel.c 18 Jul 2007 20:23:15 -0000 1.1.2.63 --- kernel.c 19 Jul 2007 01:30:16 -0000 1.1.2.64 *************** *** 1307,1311 **** void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv) { int fd; ! char dirbuf[MAXPDSTRING], *nameptr; if (tryingalready) return; newest = 0; --- 1307,1311 ---- void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv) { int fd; ! char *dirbuf, *nameptr; if (tryingalready) return; newest = 0; *************** *** 1319,1324 **** class_loadsym = 0; t_pd *current = s__X.thing; ! if ((fd = canvas_open(canvas_getcurrent(), s->name, ".pd", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 || ! (fd = canvas_open(canvas_getcurrent(), s->name, ".pat", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) { close(fd); if (!pd_setloadingabstraction(s)) { --- 1319,1324 ---- class_loadsym = 0; t_pd *current = s__X.thing; ! if ((fd = canvas_open2(canvas_getcurrent(), s->name, ".pd", &dirbuf, &nameptr, 0)) >= 0 || ! (fd = canvas_open2(canvas_getcurrent(), s->name, ".pat", &dirbuf, &nameptr, 0)) >= 0) { close(fd); if (!pd_setloadingabstraction(s)) { *************** *** 1327,1334 **** if (s__X.thing != current) canvas_popabstraction((t_canvas *)s__X.thing); canvas_setargs(0, 0); ! } ! else error("%s: can't load abstraction within itself\n", s->name); ! } ! else newest = 0; }
--- 1327,1333 ---- if (s__X.thing != current) canvas_popabstraction((t_canvas *)s__X.thing); canvas_setargs(0, 0); ! } else error("%s: can't load abstraction within itself\n", s->name); ! free(dirbuf); ! } else newest = 0; }
*************** *** 2126,2133 **** /* read a binbuf from a file, via the search patch of a canvas */ int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int flags) { ! char buf[MAXPDSTRING], *bufptr; ! int filedesc = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 0); if (filedesc<0) {error("%s: can't open", filename); return 1;} close(filedesc); return !!binbuf_read(b, bufptr, buf, flags); } --- 2125,2133 ---- /* read a binbuf from a file, via the search patch of a canvas */ int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int flags) { ! char *buf, *bufptr; ! int filedesc = canvas_open2(canvas, filename, "", &buf, &bufptr, 0); if (filedesc<0) {error("%s: can't open", filename); return 1;} close(filedesc); + free(buf); return !!binbuf_read(b, bufptr, buf, flags); }
Index: d_soundfile.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_soundfile.c,v retrieving revision 1.4.4.11.2.10.2.15 retrieving revision 1.4.4.11.2.10.2.16 diff -C2 -d -r1.4.4.11.2.10.2.15 -r1.4.4.11.2.10.2.16 *** d_soundfile.c 18 Jul 2007 21:46:35 -0000 1.4.4.11.2.10.2.15 --- d_soundfile.c 19 Jul 2007 01:30:16 -0000 1.4.4.11.2.10.2.16 *************** *** 323,329 **** int open_soundfile_via_canvas(t_canvas *canvas, const char *filename, int headersize, int *p_bytespersamp, int *p_bigendian, int *p_nchannels, long *p_bytelimit, long skipframes) { ! char buf[OBUFSIZE], *bufptr; ! int fd = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 1); if (fd < 0) return -1; return open_soundfile_via_fd(fd, headersize, p_bytespersamp, p_bigendian, p_nchannels, p_bytelimit, skipframes); } --- 323,330 ---- int open_soundfile_via_canvas(t_canvas *canvas, const char *filename, int headersize, int *p_bytespersamp, int *p_bigendian, int *p_nchannels, long *p_bytelimit, long skipframes) { ! char *buf, *bufptr; ! int fd = canvas_open2(canvas, filename, "", &buf, &bufptr, 1); if (fd < 0) return -1; + free(buf); return open_soundfile_via_fd(fd, headersize, p_bytespersamp, p_bigendian, p_nchannels, p_bytelimit, skipframes); } *************** *** 342,366 **** if (bytespersamp == 2) { if (bigendian) { ! for (j = 0; j < nitems; j++, sp2 += bytesperframe, fp++) ! *fp = SCALE * ((sp2[0] << 24) | (sp2[1] << 16)); } else { ! for (j = 0; j < nitems; j++, sp2 += bytesperframe, fp++) ! *fp = SCALE * ((sp2[1] << 24) | (sp2[0] << 16)); } } else if (bytespersamp == 3) { if (bigendian) { ! for (j = 0; j < nitems; j++, sp2 += bytesperframe, fp++) ! *fp = SCALE * ((sp2[0] << 24) | (sp2[1] << 16) | (sp2[2] << 8)); } else { ! for (j = 0; j < nitems; j++, sp2 += bytesperframe, fp++) ! *fp = SCALE * ((sp2[2] << 24) | (sp2[1] << 16) | (sp2[0] << 8)); } } else if (bytespersamp == 4) { if (bigendian) { ! for (j = 0; j < nitems; j++, sp2 += bytesperframe, fp++) ! *(long *)fp = ((sp2[0] << 24) | (sp2[1] << 16) | (sp2[2] << 8) | sp2[3]); } else { ! for (j = 0; j < nitems; j++, sp2 += bytesperframe, fp++) ! *(long *)fp = ((sp2[3] << 24) | (sp2[2] << 16) | (sp2[1] << 8) | sp2[0]); } } --- 343,361 ---- if (bytespersamp == 2) { if (bigendian) { ! for (j=0; j<nitems; j++, sp2 += bytesperframe, fp++) *fp = SCALE * ((sp2[0]<<24) | (sp2[1]<<16)); } else { ! for (j=0; j<nitems; j++, sp2 += bytesperframe, fp++) *fp = SCALE * ((sp2[1]<<24) | (sp2[0]<<16)); } } else if (bytespersamp == 3) { if (bigendian) { ! for (j=0; j<nitems; j++, sp2 += bytesperframe, fp++) *fp = SCALE * ((sp2[0]<<24) | (sp2[1]<<16) | (sp2[2]<<8)); } else { ! for (j=0; j<nitems; j++, sp2 += bytesperframe, fp++) *fp = SCALE * ((sp2[2]<<24) | (sp2[1]<<16) | (sp2[0]<<8)); } } else if (bytespersamp == 4) { if (bigendian) { ! for (j=0; j<nitems; j++, sp2 += bytesperframe, fp++) *(long *)fp = (sp2[0]<<24) | (sp2[1]<<16) | (sp2[2]<<8) | sp2[3]; } else { ! for (j=0; j<nitems; j++, sp2 += bytesperframe, fp++) *(long *)fp = (sp2[3]<<24) | (sp2[2]<<16) | (sp2[1]<<8) | sp2[0]; } } *************** *** 424,431 **** if (filetype < 0) { const char *s = filesym->name + strlen(filesym->name); ! if (strlen(filesym->name) >= 5 && !strcmp(s-4, ".aif") || !strcmp(s-4, ".AIF")) filetype = FORMAT_AIFF; ! if (strlen(filesym->name) >= 6 && !strcmp(s-5, ".aiff") || !strcmp(s-5, ".AIFF")) filetype = FORMAT_AIFF; ! if (strlen(filesym->name) >= 5 && !strcmp(s-4, ".snd") || !strcmp(s-4, ".SND")) filetype = FORMAT_NEXT; ! if (strlen(filesym->name) >= 4 && !strcmp(s-3, ".au") || !strcmp(s-3, ".AU")) filetype = FORMAT_NEXT; if (filetype < 0) filetype = FORMAT_WAVE; } --- 419,426 ---- if (filetype < 0) { const char *s = filesym->name + strlen(filesym->name); ! if (strlen(filesym->name) >= 5 && !strcasecmp(s-4, ".aif" )) filetype = FORMAT_AIFF; ! if (strlen(filesym->name) >= 6 && !strcasecmp(s-5, ".aiff")) filetype = FORMAT_AIFF; ! if (strlen(filesym->name) >= 5 && !strcasecmp(s-4, ".snd" )) filetype = FORMAT_NEXT; ! if (strlen(filesym->name) >= 4 && !strcasecmp(s-3, ".au" )) filetype = FORMAT_NEXT; if (filetype < 0) filetype = FORMAT_WAVE; }