File: scan_to_array.c

package info (click to toggle)
libowfat 0.28-6
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 4,068 kB
  • sloc: ansic: 12,863; makefile: 16
file content (12 lines) | stat: -rw-r--r-- 366 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
#include "str.h"
#include "array.h"
#include "textcode.h"

size_t scan_to_array(size_t (*func)(const char*,char*,size_t*),
			    const char* src,array* dest) {
  size_t scanned;
  size_t needed=str_len(src);
  char* x=((char*)array_start(dest))+array_bytes(dest);
  if (!array_allocate(dest,1,array_bytes(dest)+needed-1)) return 0;
  return func(src,x,&scanned);
}