1/*- 2 * Copyright (c) 1999 James Howard and Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 */ 26 27/* 28 * A really poor man's queue. It does only what it has to and gets out of 29 * Dodge. It is used in place of <sys/queue.h> to get a better performance. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/usr.bin/grep/queue.c 211364 2010-08-15 22:15:04Z gabor $"); |
34 35#include <sys/param.h> 36#include <sys/queue.h> 37 38#include <stdlib.h> 39#include <string.h> 40 41#include "grep.h" --- 13 unchanged lines hidden (view full) --- 55{ 56 struct qentry *item; 57 58 item = grep_malloc(sizeof(struct qentry)); 59 item->data.dat = grep_malloc(sizeof(char) * x->len); 60 item->data.len = x->len; 61 item->data.line_no = x->line_no; 62 item->data.off = x->off; |
63 memcpy(item->data.dat, x->dat, x->len); |
64 item->data.file = x->file; 65 66 STAILQ_INSERT_TAIL(&queue, item, list); 67 68 if (++count > Bflag) 69 free(dequeue()); 70} 71 --- 33 unchanged lines hidden --- |