{
  "id": 13553964,
  "title": "Removing Duplicates from a Simple Dynamic Array for C",
  "url": "https://urgent.news/2026/10/10/removing-duplicates-from-a-simple-dynamic-array-for-c",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-10T22:15:01.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/pauljlucas/removing-duplicates-from-a-simple-dynamic-array-for-c-1mlg"
  },
  "original_language": "en",
  "account": "The provided code aims to remove duplicate elements from a sorted array of symbols in a C program. It does this by iterating through the array and comparing each element with the last unique element. If the current element is not equal to the last unique element, it is considered unique and the last_unique pointer is updated. If the current element is equal to the last unique element, it is considered a duplicate. In this case, the code checks if a free function is provided to clean up the memory used by the duplicate element. If the free function is not NULL, it calls the function to free the memory.\n\nThe code uses pointer arithmetic instead of an index variable, as it would be more efficient to increment by the size of each element directly. This eliminates the need for calculating element addresses and multiplying by the index variable i.\n\nTo optimize the code further, it introduces the concept of batch processing. Instead of calling the memcpy function multiple times for individual elements, the code keeps track of the start of the current batch of unique elements (batch_src) and the length of the batch (batch_len). This allows for copying multiple unique elements together in a single call to memcpy, reducing the number of function calls and improving performance.",
  "summary": "Introduction Previously, I described a full implementation for a simple dynamic array in C that I’ve been using in my include-tidy (Tidy) project. When Tidy prints an #include directive that the file being tidied is missing, it, by default, includes a comment containing the symbol(s) referenced, e.g.: #include <stdio.h> // printf, puts When tidying a C++ source file, there can be duplicate names…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}