Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6063231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:08:32+00:00 2026-05-23T09:08:32+00:00

I am using a circular queue as a data buffer. I am using a

  • 0

I am using a circular queue as a data buffer. I am using a char array to hold the data and my problem is when I need to view the data in the buffer in its original order. the reordering of the buffer is taking up most of the processing time with 64%. I need this to be as optimized as possible because I use this buffer to search for signatures in gigabytes of data. Any optimization suggestions would be greatly appreciated and/or any other suggestions on how to store this buffer and easy convert it to a char array for processing. thanks in advance

edit: I apologize what I mean by reorder is if the data is “abcdef” then there is a good chance the buffer will look like “defabc” so I need to reorder the buffer to “abcdef”

queue structures:

typedef struct item{
unsigned char* data;
int length;
} item;

typedef struct queue{
unsigned char *data;
int front;
int back;
int length;
int size;
} queue;

reorder function:

int toStr(queue *ptr, item *ret){
int length;
int i;
int j;
int back = ptr->back;
int size = ptr->size;
char* tmp;
char* tmp_data;

if(ptr->length == 0){
    return 0;
}

tmp = ret->data;
ret->length = ptr->length;
tmp_data = ptr->data;
i = ptr->front;
j = 0;
while(i != back){
    //ret->data[j] = tmp_data[i];
    tmp[j] = tmp_data[i];
    ++i;
    ++j;
    if(i > size){
        i = 0;
    }
}

return 1;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:08:32+00:00Added an answer on May 23, 2026 at 9:08 am

    Right now you’re copying all the data just to see it in order. I think I’d provide a function to convert a subscript into a pointer to the correct place in the buffer:

    unsigned char *sub(queue const *q, int subscript) { 
        return q->data + (front + subscript) % q->size);
    }
    

    Then using the data in order is something like:

    for (i=0; i<q->size; i++)
        printf("%c\n", *sub(q, i));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to draw text onto a window HDC along a circular path using
I have a circular, statically allocated buffer in C, which I'm using as a
Iterating forward through a circular buffer without using a conditional is easy with the
I am using a circular ProgressBar in my Activty.My Problem is this it is
I'm using the 'TPCircularBuffer' class for creating a circular buffer object, from this website
Is there a way to define circular references without using pointers? I need to
Greetings, I'm trying to implement a Deque using a circular array that extends when
I'm using Visual c++. I'm trying to implement a circular buffer, this CB must
I'm having a lot of trouble implementing this deque using a circular array; in
I am a using a boost regex on a boost circular buffer and would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.